Has anyone had any issues using Values Lists at the column level?
I have created the following ValueLists
lsAssetClass = (from a in DataBaseManager.Core.AssetClassselect a).ToList<AssetClass>(); //creates a list of LINQ objects
vAssetClass = lsAssetClass.ToValueList(
"AssetClassDesc", "AssetClassCode");
//Custom extension method used to create a value list
lsPortSubCat = (from pcat in DataBaseManager.Core.PortfolioSubCategory select pcat).ToList<PortfolioSubCategory>();
vPortSubCat = lsPortSubCat.ToValueList(
"PortSubCategoryDesc", "PortSubCategoryCode");
//Then I'm setting the ValueList properties of each column on the Initialize Layout event
e.Layout.Bands[0].Columns[
"AssetClassDesc"].ValueList = ValueLists.vAssetClass;
"PortfolioCategoryDesc"].ValueList = ValueLists.vPortSubCat;
//Everything works fine except for when I try to access the values in the lists
string
asset = (string)dgSecuritySetup.Rows[0].Cells["AssetClassDesc"].Value;
string port = (string)dgSecuritySetup.Rows[0].Cells["PortSubCategoryDesc"].Value;
/*The issue is that "asset" ends up being the correct value (i.e If I see "Equity" on the grid, I get its code ("EQ") when I access the cell value, as expected. When I try to do the same for "port" I always get back the displayed text rather than the corresponding value in the value list (i.e I get "Long-Spec" when I should get "LNGSPEC"). I double checked to make sure the Value List was still set when I tried to access the cell value (which it was) and I double checked the ValueList to make sure the display text/data values were set up correctly (which they are, "Long-Spec" maps to "LNGSPEC") */
The UltraGrid is using row layouts and each column style is DropDownList.
Any ideas? This seems like a bug.....
Mike, the code was copied from VS2008. Anything I copy to the IF forums comes out distorted, doesn't seem to be an issue anywhere else....
I'm not sure the data types are the problem here either... the columns are all strings as are the DataValues in the value lists.
I'll try to replicate in a sample and send to you
The code you posted here got corrupted somehow, so it's really hard to read. This seems to be an issue with our forums. Out of curiousty, where did you copy and paste this code from? I've seen this problem happen on the forums before, but it never happens when I paste from Visual Studio.
Anyway, can you duplicate this behavior in a small samplr project? My guess is that if the DataValue is not being properly translated to the display text that there's a data type mismatch somewhere along the way. The value of the grid cell has to exactly match the DataValue of the ValueListItem or it won't work.
As a follw up, I was able to access the value in the value list by using the following:
port = (
string)ValueLists.vPortSubCat.ValueListItems[ValueLists.vPortSubCat.FindStringExact(port)].DataValue;
All the more reason to think this is a bug. The value list definitely contains the correct value.
I am having the similar issue where i have a ultragrid with 4 ultradropdown and i am not able to access the value .
I am binding ultradropdown to ultragrid at cell level
e.Row.Cells(COLUMN_COUNTRY).ValueList = uddl_Country
e.Row.Cells(COLUMN_STATE).ValueList = uddl_States
They have parent child relationship and since each row can have different values i am binding them at cell level.
I was able to get the value by drilling down into selected cells valuelist
strStateValue = CStr(ug_MainGrid.ActiveCell.ValueList.GetValue(ug_MainGrid.ActiveCell.ValueList.SelectedItemIndex))
This might not be a great ans but this solved the problem.
Also another problem i am facing is even after setting the selected value property in the dropdown the value in dropdown is not getting selected.