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
I got to work sometimes with very weird behavior. As long as the currently stored value is non-zero, the dropdown selection is saved correctly in the cell. If I choose the item with a value of 0, then that cell can no longer be updated. It get's stuck with 0. Btw, 0 is a valid value in the dropdown list.Also, this only works if I postback on the grid's UpdateCell event. If I do UpdateRow, the cell won't save no matter what. Then the cell never seems to recognize a change.To simplify my example, I have dropdown list like this:Value Text0 Select…1 Red2 Blue3 GreenThe grid only saves a newly selected Value in the cell if the current cell Value is not 0. Plus this only works if I do a postback on UpdateCell.If I set a cell to 0, then the cell no longer updates. It stays 0 and UpdateCell is not called if I change that cell.
Any idea what might cause this freakiness?
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.