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
close icon

GridControl get row Changes back into Datatable

I am trying to save changes back to the original datatable that was used to populate the grid. I currently set the Grid(nRow,0).Tag value to indicate that the row has changes, But is there a simply way to iterate a row object or return a datarow/datatable object from the Grid rows that have been changed???

3 Replies

AD Administrator Syncfusion Team November 22, 2005 09:20 AM UTC

Not if you are using a GridControl. If you have a DataTable and are using it by moving the data into a GridControl cell by cell, then the grid has no knowlegde of the datatable. One thing you could do is to handle the SaveCellInfo event. There, based on e.RowIndex and e.ColIndex, you could save e.Style.CellValue back to your DataTable at that point. Then the DataTable would be current at all times.


BH Brian Harrison December 20, 2005 10:53 PM UTC

II tried using the SaveCellInfo Event and set the Row.Tag to true so I can find changed data later, however this ends in a endless loop and a stack overflow. Any Ideas. Basically anytime data changes I want to flag the raow much like a datatable sets the rowChanged flag, then iterate during a save and process the changes only back to the Database. ???? >Not if you are using a GridControl. If you have a DataTable and are using it by moving the data into a GridControl cell by cell, then the grid has no knowlegde of the datatable. One thing you could do is to handle the SaveCellInfo event. There, based on e.RowIndex and e.ColIndex, you could save e.Style.CellValue back to your DataTable at that point. Then the DataTable would be current at all times.


AD Administrator Syncfusion Team December 21, 2005 04:55 PM UTC

Hi Brian, I don''t think there is an easy way since it is an unbound Grid with its own datastore. I think your approach should be good i.e., you can set the rowheader''s tag when the data changes for that particular row in SaveCellInfo. If you set the Tag''s value in the SaveCellInfo event handler, it will trigger the SaveCellInfo again leading to recursive loop. You can avoid this by making sure it doesn''t trigger for rowheader (0 th Column). Something like: private void gridControl1_SaveCellInfo(object sender, GridSaveCellInfoEventArgs e) { if(e.ColIndex != 0) // Don''t trigger SaveCellInfo for rowheader.. this.gridControl1[e.RowIndex, 0].Tag = "true"; } Best regards, Jay

Loader.
Live Chat Icon For mobile
Up arrow icon