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.....
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.
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.