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

Parents
  • 69832
    Offline posted

    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.

Reply Children
No Data