Adding New Row to GridDataBoundGrid

I am having a problem with my GridDataBoundGrid. One of the columns in the grid is a button. When the button is pressed a new form is launched. This new form makes modifications to the datarow from the grid. There seems to be a problem in the case where the user clicks on the button for a new row. If the user makes changes to the row, through the form, and then goes to another row in the grid, w/o directly making changes through the grid, the row disapears. To add the new row, I am doing the following: CurrencyManager cm = (CurrencyManager) this.BindingContext[grid.DataSource]; if (((e.RowIndex - 1) == cm.Count)) { grid.Binder.AddNew(); grid.Binder.SetCurrentPosition(cm.Count-1, false); } Thanks, Michael Sabin

2 Replies

AD Administrator Syncfusion Team December 5, 2005 05:54 PM UTC

Something to try. Instead of calling grid.Binder.AddNew, try calling cm.AddNew() (and maybe followed by cm.EndCurrentEdit()).


AD Administrator Syncfusion Team December 5, 2005 07:01 PM UTC

Thanks, that worked. The only problem was that there was a repaint issue with the grid when I did that. Here is how I got it to work nicely: if (((e.RowIndex - 1) == cm.Count)) { this.grid.BeginUpdate(); grid.Binder.AddNew(); cm.AddNew(); this.grid.Binder.SetCurrentPosition(cm.Count - 2, false); this.grid.Binder.RemoveRecords(cm.Count - 1, cm.Count -1); this.grid.EndUpdate(); }

Loader.
Up arrow icon