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. Image for the cookie policy date
close icon

Formatting exception

we recently migrated to 4.0 and what is happening is in GDBG when user moves to cell whose underlying celltype is currency and press the del key and then try to tab out.. we get the following exception. I have attached the source code, and to reproduce this problem scroll to qty column and press del key and then try to tab out. u shud see the below exception. System.ArgumentException: System.FormatException: Input string was not in a correct format. at System.Number.ParseDouble(String s, NumberStyles style, NumberFormatInfo info) at System.Double.Parse(String s, NumberStyles style, IFormatProvider provider) at System.Convert.ToDouble(String value, IFormatProvider provider) at System.String.System.IConvertible.ToDouble(IFormatProvider provider) at System.Convert.ToDouble(Object value) at System.Data.Common.DoubleStorage.Set(Int32 record, Object value) at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn''t store <> in Qty Column. Expected type is Double. at System.Data.DataColumn.set_Item(Int32 record, Object value) at System.Data.DataRow.set_Item(DataColumn column, Object value) at System.Data.DataRowView.SetColumnValue(DataColumn column, Object value) at System.Data.DataColumnPropertyDescriptor.SetValue(Object component, Object value) at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.SaveCellInfo(GridSaveCellInfoEventArgs e) catched at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.SaveCellInfo(GridSaveCellInfoEventArgs e) in :line 0 System.ArgumentException: System.FormatException: Input string was not in a correct format. at System.Number.ParseDouble(String s, NumberStyles style, NumberFormatInfo info) at System.Double.Parse(String s, NumberStyles style, IFormatProvider provider) at System.Convert.ToDouble(String value, IFormatProvider provider) at System.String.System.IConvertible.ToDouble(IFormatProvider provider) at System.Convert.ToDouble(Object value) at System.Data.Common.DoubleStorage.Set(Int32 record, Object value) at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn''t store <> in Qty Column. Expected type is Double. at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.SaveCellInfo(GridSaveCellInfoEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.Syncfusion.Windows.Forms.Grid.IGridModelDataProvider.SaveCellInfo(GridSaveCellInfoEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType, Boolean dontRaiseSaveCellInfoEvent, Boolean copyReferenceOnly) at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType) at Syncfusion.Windows.Forms.Grid.GridModel.ChangeCells(GridRangeInfo range, GridStyleInfo[] cellsInfo, StyleModifyType modifyType) at Syncfusion.Windows.Forms.Grid.GridModel.Syncfusion.Windows.Forms.Grid.IGridVolatileDataContainer.ChangeCell(Int32 rowIndex, Int32 colIndex, GridStyleInfo style) at Syncfusion.Windows.Forms.Grid.GridVolatileData.set_Item(Int32 rowIndex, Int32 colIndex, GridStyleInfo value) at Syncfusion.Windows.Forms.Grid.GridStyleInfoIdentity.OnStyleChanged(StyleInfoBase style, StyleInfoProperty sip) at Syncfusion.Styles.StyleInfoBase.OnStyleChanged(StyleInfoProperty sip) at Syncfusion.Windows.Forms.Grid.GridStyleInfo.OnStyleChanged(StyleInfoProperty sip) at Syncfusion.Styles.StyleInfoBase.EndUpdate() at Syncfusion.Windows.Forms.Grid.GridCellModelBase.ApplyText(GridStyleInfo style, String text) at Syncfusion.Windows.Forms.Grid.GridStyleInfo.ApplyText(String text) at Syncfusion.Windows.Forms.Grid.GridStyleInfo.set_Text(String value) at Syncfusion.Windows.Forms.Grid.GridCurrencyTextBoxCellRenderer.OnSaveChanges() at Syncfusion.Windows.Forms.Grid.GridCellRendererBase.RaiseSaveChanges() at Syncfusion.Windows.Forms.Grid.GridCurrentCell.ConfirmChanges(Boolean closeDropDown) catched at Syncfusion.Windows.Forms.Grid.GridCurrentCell.ConfirmChanges(Boolean closeDropDown) in :line 0

WinApp100.zip

1 Reply

AD Administrator Syncfusion Team February 8, 2006 09:33 AM UTC

Hi Yogi, You can try setting the CellValueType of the currency column to Double and handle the CurrentCellValidating Event of the grid. The code below will help you. this.gridBoundColumn2.StyleInfo.CellValueType = typeof(System.Double); //CurrentCellValidating Event private void gridDataBoundGrid1_CurrentCellValidating(object sender, System.ComponentModel.CancelEventArgs e) { GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; if(cc.ColIndex == this.gridDataBoundGrid1.Binder.NameToColIndex("Qty")) { if(cc.Renderer.ControlText == "") { cc.Renderer.ControlValue = DBNull.Value; } } } Please refer to the Sample modified.Sample Thanks, Rajagopal

Loader.
Live Chat Icon For mobile
Up arrow icon