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

Adding Rows to a DataBound Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

20135 Oct 11,2004 01:01 PM UTC Oct 11,2004 03:21 PM UTC WinForms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On October 11, 2004 01:01 PM UTC

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? Thanks, Ben Lamb.

Administrator [Syncfusion]
Replied On October 11, 2004 03:21 PM UTC

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.)

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

;