We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DBNull in Cell that ecpects int

Thread ID:

Created:

Updated:

Platform:

Replies:

40315 Jan 31,2006 01:58 PM UTC Jan 31,2006 03:58 PM UTC WinForms 2
loading
Tags: GridControl
sahon
Asked On January 31, 2006 01:58 PM UTC

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?

sahon
Replied On 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?

Administrator [Syncfusion]
Replied On 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; }

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;