The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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?
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?
ADAdministrator 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;
}