I''ve got a GridDataBoundGrid that allows the addition of new rows. Using a combination of event handlers I prevent the user entering any information except in one cell in the last row.
The idea is that the user types something into this cell and once they''re done the other information for the row is looked up into the background. A new row is then added (by the grid) for the user to enter another value.
I current have a handler linked up to CurrentCellEditingComplete that calls the procedure to lookup the data for the row. It expects to find a row in the datatable that has been added by the grid.
If I type a value in the cell and move the current cell using the up arrow, the grid adds the new DataRow it has created to the DataTable and everything works fine. If the user presses enter the procedure to lookup the information is called without the grid having first added the new row to the DataTable.
1) Is there any way I can force the grid to add the new row to the DataTable?
2) Can I can access the new row and add it to the DataTable myself?
3) Is there a better event handler to use that gets called after the user has pressed Enter and grid?
ADAdministrator Syncfusion Team October 11, 2004 10:21 AM
1) You can call grid.CurretnCell.EndEdit and grid.Binder.EndEdit and this should force the grid to save any pending changes. But you need to be care where/how you call these methods to avoid recursive calls. You could try using the CUrrentCellMoved event. But doing 2 is probably a better option.
2) Yes. You can catch the CurrentCellMoving event. If grid.CurrentCell.MoveToRowIndex is the AddNew row, go ahead and add a DataRow directly to your DataTable. This will give you a chance to populate fields before your user starts to edit things if that is what you want.
3) Normally, changes are saved as you leave the row. So, you could try grid.RowLeave or if you want to save them as the user leaves the cell (not necceasily the row), you can try CurrentCellMoved (using grid.CurrentCell.MoveFormRowIndex to know what the old row was.)