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

Problem with adding manually a new row to the grid

Hi all, Please help me. I using GridDataBoundGrid. I code for 1 button to add new row: ROPStoreVO oROPStoreVO = (ROPStoreVO)gridROPStore.DataSource; if (oROPStoreVO == null) return; DataRow drwNewRow = oROPStoreVO.NewRow(); oROPStoreVO.Rows.Add(drwNewRow); this.gridROPStore.Focus(); this.gridROPStore.CurrentCell.MoveTo(gridROPStore.Model.RowCount, 1); bool isRet = this.gridROPStore.CurrentCell.BeginEdit(); It ran OK when I clicked on this button. But, when I clicked on header to sort data, and then click the button. It still added a new row but the new row went ahead. I want a new row go to the bottom. Anyone help me. Thank you so much. Phuoc Tu.

2 Replies

AD Administrator Syncfusion Team January 28, 2005 03:52 AM

The GridDataBoundGrid only displays the rows in your datasource, and displays them in the exact order that they appear in the datasource. If you are using a DataTable as the datasource, then when you sort it, the datasource is really DataTable.DefaultView (so you datatable can be displayed as sorted.) So, when you add a row to your datatable, the defaultview will position it according to its Sort property. This is all done outside the grid, and is completely handled by the DataTable. If you want to keep using a DataTable as your datasource, to avoid this behavior means you have to handle all the sorting yourself and not relie on the sortting that depends upon Datatable.DefaultView. This takes some non-trivail coding. While it is not exactly what you need, here is a sample that shows one way to manage this problem. The idea is to handle grid.Model.QueryCellInfo and use this event to control the display order of the rows through an indexer class. This technique can be adapted to not move new rows added at the bottom until the next sort.

AD Administrator Syncfusion Team January 28, 2005 04:46 AM

Here is a smple that is colser to what you want. http://www.syncfusion.com/forums/Uploads/GridDataBoundGridCustomSorting_Forum.zip

Live Chat Icon For mobile
Up arrow icon