Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
320
Column bound to an int? or Nullable<int>
posted

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...