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?
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.
Hm...
"I will change null value to 0 before leaving the edited cell. Please tell me, how can I do it?"
Any suggestions?
Ok, it seems i see the algorithm of solution.
I will change null value to 0 before leaving the edited cell.
Please tell me, how can I do it?
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.
I had a similiar problem and found the solution on the EntitySpaces forum (as I'm using that as a DataSource):
http://community.entityspaces.net/forums/thread/5379.aspx
Essentially use:
foreach (UltraGridColumn column in this.grid.Rows.Band.Columns)
column.Nullable = Infragistics.Win.UltraWinGrid.Nullable.EmptyString;
}