I have a grid that when populated may or may not have null values for a column that is a string.
If the data returned is already null everything works fine. If the string column had data and I step into the column and delete all the data I get a message stating that there is a Data Error - Unable to update the data value: Object of type 'System.DBNull' cannot be converted to type 'System.String'.
How can I allow a column to go back to a null value once it contained data?
I have the same problem
with error "Unable to update the data value: Object of type 'System.DBNull' cannot be converted to type 'System.Nullable`1[System.Decimal]'."
It seems the only way is to use CellError event, because I cann't change my Datatype filed to nullable value.
alex_blokha said:Unable to update the data value: Object of type 'System.DBNull' cannot be converted to type 'System.Nullable`1[System.Decimal]'.
To address this, set the Nullable property on the corresponding WinGrid column to "Nothing". This will store an actual null value ("null" in C#, "Nothing" in VB.NET) whenever the cell's value would be null. A Nullable Decimal field knows what to do with this kind of a "null' value.
john_m,
john_m said:Is it as easy as adding a list item that will map an empty string to the correct type of Null?
I'm bumping into this issue as well. My case is a little more convoluted... there's an UltraCombo being used as the EditorControl.
Any ideas on how I should set up the data in my combo to allow the user to empty out a cell? Is it as easy as adding a list item that will map an empty string to the correct type of Null?
Thanks
Thank you, this advise was helpfull.
alex_blokha,
I've discussed this behavior in more detail with our developers, and we'd like to take a closer look to see if we can handle this situation in a more automatic fashion.
I'm passing the information on this thread to Developer Support, who will create a support case for you.
In the meantime, you should still be able to set the Nullable property of the column appropriate to what the underlying data source expects.