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

Error when entering data after deleting rows

I appreciate the great support you provide! We have a GridDataBoundGrid bound to a child table in a dataset. The grid displays TimeCardDetails children of one TimeCard parent at a time. Before deleting the parent record we call CurrentCell.EndEdit() and Binder.EndEdit(). The child records are successfully deleted and the grid is clear of data. When going into the grid to try and enter new data is when the issue occurs. If one child row was there before the delete we can enter new data without problem. Our code creates a new TimeCard parent when the first detail is added to the grid for the selected day. However, if more than one row of details was in the grid before deletion we get an null reference error. Here is part of the stack: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.BeginEdit() at Syncfusion.Windows.Forms.Grid.GridDataBoundGrid.BeginEdit() at Syncfusion.Windows.Forms.Grid.GridDataBoundGrid.OnCurrentCellChanging(CancelEventArgs e) at Syncfusion.Windows.Forms.Grid.GridControlBase.RaiseCurrentCellChanging() at Syncfusion.Windows.Forms.Grid.GridCurrentCell.NotifyChanging() at Syncfusion.Windows.Forms.Grid.GridCellRendererBase.NotifyCurrentCellChanging() at Syncfusion.Windows.Forms.Grid.GridTextBoxCellRenderer.set_TextBoxText(String value) at Syncfusion.Windows.Forms.Grid.GridDropDownGridListControlCellRenderer.SetComboBoxText(String s, Boolean validate, Int32 index) at Syncfusion.Windows.Forms.Grid.GridDropDownGridListControlCellRenderer.ListControlMouseUp(Object sender, MouseEventArgs e) You can see that the error occurs when the GridModelDataBinder.BeginEdit() method is called. Do we need to reset the binder or do something else to create a blank slate? It works fine when there hasn''''t just been a delete. We are coding in VB.Net. Thanks!

1 Reply

AD Administrator Syncfusion Team August 4, 2004 06:53 PM UTC

Are you using You might experiment with setting different values o fthese grid.UseOptimizedListChangeEvent and grid.OptimizeInsertRemoveCells to see if any combination of these properties will allow your code to work. One thing I think would clearly work would be to reset the hierarchies and re-add them as in teh code below. ''Reduce flicker gridDataBoundGrid1.BeginUpdate() gridDataBoundGrid1.Binder.ResetHierarchyLevels() gridDataBoundGrid1.DataSource = Nothing gridDataBoundGrid1.DataMember = "" gridDataBoundGrid1.DataSource = VariableData gridDataBoundGrid1.DataMember = "Parent" ChildrenTable.CreateAllHierarchy() '' Reduce flicker gridDataBoundGrid1.EndUpdate()

Live Chat Icon For mobile
Up arrow icon