I have added a valuelist column to my grid, with values from a dataset.
ErosionModel = grdGenericPercentBrand.DisplayLayout.ValueLists.Add("ErosionModel");
ErosionModel.ValueListItems.Add(erosionModelDataID, erosionModelRateName)
What event should I use to capture the erosionModelDataID of the valuelis from that given cell? I need to populate other cells on the grid based on this value.
peryan77 said:Would this work if the Valuelist name is the same for each row, along with the same column names of the valuelist?
So here is my approach, let me know if it makes sense,
I have a datatable in memory, e.g.
GeographyID, ErosionModelDataID, ErosionModelName
In my grid I have a column called GeographyID,
In my grid I add a dropdown column and I need to populate each dropdown with values from the datatable where geographyID are equal.
If I understand,
In the initalize row event I can add
ValueList ErosionModelValueList = new ValueList( );
Then load value list by using the row's geographyID to grab the related records from the datatable.
Would this work if the Valuelist name is the same for each row, along with the same column names of the valuelist?
You essentially are adding only one ValueList to your grid, which you're reusing across all cells in a column.
What it sounds like you want is a different ValueList based on some other value. You should set the key of that ValueList based upon whatever value you're using to build the ValueList.
Alternately, you can avoid adding the ValueList to the control's ValueLists collection in the first place, and instead associate each cell in your column with a new ValueList when you need it. The downside to this approach is that you might duplicate similar ValueList instances.
By the way, I suggest moving the logic you have in your "loader" method into the InitializeRow event handler instead. That way, you can avoid having to loop through all the rows in the grid, and you can easily change what ValueList to use whenever you change the value you're using to determine what data to load into your ValueList.
I think the problem is in my loader,
This line of code seems to prevent me from adding another valuelist in the same column after the first one. However, if I remove it then I get a Key already exists error, so it seems I can add only one.
if (!grdGenericPercentBrand.DisplayLayout.ValueLists.Exists("ErosionModel"))
My question is,
How do I get a ValueList for each row in a column? Or would the approach be to use one value list object with different values in it on a row by row basis?
Something is wrong.
I keep getting the same DataValue ID for all of the cells if I choose the same text. Eventhough the text might be the same its datavalue should be different. It is different in the dataset.
ie
ErosionModelDataID ErosionModelName
1 Conventional
2 Agressive
3 Conventional
4 Agressive
cell 1 might have 1,2 and the cell below it (in the same column) might have 3,4. No matter what cell I click I get the same ID from the text.
I know my loader is correct...