GDBG has combobox with ValueMember of type int. I can select values from combobox without any problems. When I try to press DELETE, text part of combobox becomes empty and I want to save there DBNull.value, but Messagebox appears that this cast is not possible:
System.ArgumentException: Input string was not in a correct format.Couldn''t store <> in TableID Column. Expected type is Int16. ---> System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) ......
Is it possible to handle such situation?
SA
sahon
January 31, 2006 02:24 PM UTC
just found in forum
void dtg_CurrentCellValidating(object sender, CancelEventArgs e)
{
GridCurrentCell cc = this.dtg.CurrentCell;
if (cc.ColIndex == (int)ColumnNames.Table)
{
if (cc.Renderer.ControlText == "")
cc.Renderer.ControlValue = DBNull.Value;
}
}
Is it right approach?
AD
Administrator
Syncfusion Team
January 31, 2006 03:58 PM UTC
Hi Sahon,
The approach is right. But you can get the column index using the this.gridDataBoundGrid1.Binder.NameToColIndex("ColumnName"); Below is a code snippet.
Regards,
Calvin.
private void gridDataBoundGrid1_CurrentCellValidating(object sender, System.ComponentModel.CancelEventArgs e)
{
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
if(cc.ColIndex == this.gridDataBoundGrid1.Binder.NameToColIndex("ColumnName"))
if (cc.Renderer.ControlText == "")
cc.Renderer.ControlValue = DBNull.Value;
}