Just wondering if anyone has seen this before. I believe it to be a defect and am documenting it here so a search could find it.
If a column is bound to a business entity or datasource defined as a Nullable<int> or int? you cannot assign the value null to it without a cast.
e.Row.Cells["xx"].Value = null; will give a run time error.
e.Row.Cells["xx"].Value = (Nullable<int>) null; will work.
This is not a .NET issue since Nullable<int> x = null; will work just fine.
*** Update, further tests showed that even the 2nd cast above fails. See solution below...
I was able to reproduce the error message aspect of this; that is a bug, which will be addressed in a future release of the control. I tried casting the value, however, and got the same error, so I'm not sure how you were able to get around the problem with that approach. Note that setting the column's Nullable property to 'Nothing' actually does not prevent this.
You might want to log an incident with Developer Support so that you receive a notification when the fix becomes available (reference bug ID 15870)
[EDIT] Setting the Nullable property does in fact work, I applied the property setting to the wrong column when I tested it. A thousand pardons for the misinformation.
Thanks for this information. All of sudden even the cast I am doing above is not working. (maybe I tested the wrong thing previously)
i.e. Even row.Cells["id"].Value = (Nullable<int>)null;
is now giving a cast exception. I think it might have something to do with the DataType shown for the column:
System.Nullable`1[System.Int32]
It looks look a pseudo defined type.