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
530
Cannot set column '<COLUMN>' to be null. Please use DBNull instead.
posted

We are using XamMaskedEditor in the XamDataGrid and when we use a required field mask like '###-##-####', and blank the value out using the backspace, when it gets to a blank value, we get a DataError in the XamDataGrid : Cannot set column '<COLUMN>' to be null.  Please use DBNull instead.

We can catch the error in the DataError as such :

 if (e.Message.Contains("Please use DBNull instead"))

{

e.Cell.Value =

DBNull.Value;

e.Cancel =

true;

}

 But we feel that is a hack.  Is there a more proper way to tell the XamMaskEditor to coerce a blank string to DBNull and not Null?  When we bind this XamMaskEditor to the same dataset not in a XamDataGrid, we don't experience the error, so we feel the issue might be more with the binding between the MaskedEditor and the Grid.