Hello,
I set a cell with numeric editor in the xamDataGrid.
When I erase the content of the cell, it returns DbNull.
How Can I change it, to return Null instead of DbNull?
Thanks in advance,
Max
I have the same problem. When I clear the text in the XamNumericEditor the ConvertBack in the converter specified on the Editor's Value binding is reporting the value as DBNull.
Here's the binding:
Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type NS:View}}, Path=Master.CurrentlyEditedItem.NullableDouble, Converter={StaticResource DoubleToPercentage}}"
ValueType="{x:Type System:Double}" Mask="nnn%"
The converter itself actually has input and output of both double it's just multiplying or dividing by 100.
I can fix it by just checking for DBNull along with Null, it's just weird that it would be an issue at all.
Reflector reveals the reason?
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ConvertDisplayTextToValue(string displayText, out object value, out Exception error)
{
error = null;
value = null;
try
value = this.ValueToDisplayTextConverterResolved.ConvertBack(displayText, base.ValueType, this, base.FormatProviderResolved as CultureInfo);
if (value == null)
if ((displayText == null) || (displayText.Length == 0))
value = DBNull.Value;
}
else
error = Utils.GetTextToValueConversionError(base.ValueType, displayText);
return false;
catch (Exception exception)
error = exception;
return true;
I'm not using ClearCellContents command. The DbNull is returned when I clear the content of the field with the backspace key.
The grid is bound to a collection, not to a DataTable.
The type of the field is int, the editor is xamNumericEditor.
Hello Max,
Are you using ClearCellContents command? This will clear the cell to its default value (according to the value type).
Have you bound your XamDataGrid to a DataTable? What is the type of that field?