I have a simple WebGrid with an Int32 column I set to a dropdownlist. I have the dropdown list referencing an ObjectDataSource as follows:
WebGrid Column
Type: DropDownListBaseColumnName: ClientIDDataType: System.Int32Key: ClientID
ValueList:
DataMember: (blank since I'm using an ObjectDataSource which creates it's own dataview)DataSourceID: dsClientsDisplayMember: DescriptionDisplayStyle: DisplayTextKey: ClientIDValueMember: ClientID
Everything seems to work fine at first. ClientID ints in the database properly display as client name strings in the column. I can doubleclick the cell to show the dropdown and select from client name strings. This would imply the datatypes match between column and dropdownlist, right?
But when I save either through UpdateRow ajax or a postback, this column saves a NULL into the database. Every other grid column saves fine, so updating works. Oddly, if I set DisplayStyle in the ValueList to DataValue, it will save my selection, but then the dropdown list only shows the ClientIDs (i.e. numbers). In other words, I can get it to correctly display the client names based on original database ints, but it just won't save an int back to the database.
Thanks for any ideas.
Jim
Hello Gaurav,
Thanks for sharing the solution in public forums -- much appreciated. I am sure this will be helpful to a lot of developers in the future.
Thanks again.
I see this post is pretty old, but just for records for anyone who might face this problem:
I had a similar issue and got around it by calling DataBind for the ValueList object on page load:
UltraWebGrid1.DisplayLayout.Bands[0].Columns[0].ValueList.DataBind();
Thanks,
Gaurav
OK. Sorry I've been slow to respond but I really don't understand ObjectDataSources, so I'm back to questions about matching the data types. (It's all I got. ;-) Is the ClientID returned by the GetData method always Int32? (Unless ObjectDataSources a very unlike SqlDataSources, this will not be determined by the .Type of the InsertMethod parameter.) You might want to trap the .Selected event and check the actual type of the incoming data (from both DataSources).
row.DataChanged should work regardless of the actual values, so long as you actually make a change.
Another option would be to submit this to User Support, at: http://devcenter.infragistics.com/Protected/SubmitSupportIssue.aspx. That will usually get you a reply within a week. For best results, attach a working application based on the Northwind database that illustrates your problem. After that, the reply is sometimes "We have determined that this is a bug and we have reported it to the development team" or "We have determined that this is a bug that we fixed in version 8.2". In which case, the next hotfix may or may not include a fix to your problem.
Please keep the rest of us posted.
Sorry for the confusion. The color dropdown was just an example to help explain what's in fact happening with my Client dropdown column referenced above.
What you see above is the exact code I'm using and it's pretty much out of the box. I'm not doing any client-side js or doing anything in overridden event calls, etc.
As best as I can tell, the issue seems to be row.DataChanged not being set when I choose a dropdown choice unless the previous choice is a valid non-zero choice. Any way to force this on a dropdown selection?
JamesGrote,
The good thing about posting all your markup is that I can try to find the glitch; the bad thing is I sometimes have to look through a lot of ... ;-)
This color column is not the same column as the first one you were talking about, right? So let me suggest you re-visit all the stuff about datatype matching that I posted above. And since I don't see a color dropdown column above, I (again) suggest that you post the relevant markup and code.
Short of that, I'm coming up with lame questions like "Could the zero have somehow/somewhere become an alpha 'O'?" And I'm sure you're able to think of those kinds of things without my help.