views:

27

answers:

1

This is what I am trying to achieve :
1)DataTable populated using data from non database source
2)This table is bound to a DataGridView using BindingSource
3)The DataGridView is updated by the user, so that some cells now have new values.
4)Because the table is bound to the datagridview its values are updated.
How do i get only the updated rows(the rows which have been edited) in the grid/datatable?

I have tried :

DataRow[] updatedRows = _table.Select(null, null, DataViewRowState.ModifiedCurrent);

But this always returns 0 rows. Is there a way to get only the modified rows?

Worst case : Keep a copy of the original table
Get the new table from the datagridview datasource
compare all rows.

Thanks!

A: 

How about this:

DataTable changedRecordsTable = dataTable1.GetChanges();

You can find more details at How to: Retrieve Changed Rows

DOK
I did have to add : _table.AcceptChanges()
Oh, good. I'm glad it worked for you.
DOK