tags:

views:

27

answers:

1

Updating the first record listed in my DataGridView that is bound to my DataTable. When I run Save process I run through this line of code to get all records that have been modified:

DataTable modifiedRows = unitDataDT.GetChanges(DataRowState.Modified);

If I have changed the first record in my DataGridView my modifiedRows DataTable is Null. If I change any of the following records they are in my modifiedRows DataTable.
I have tried changing other records in my DataGridView first and then changing the first record then running the Save process and still....other records are there and the first record is not.....

Also....I checked the unitDataDT and it has the change. I sorted the datagridview to try and update a different record and it still did not add the change to the modifiedRows Datatable....so it seems to not work for the first record listed in the DataGridView.

Any ideas?

A: 

Found my issue....although not sure why it just affected the first row displayed. I added this line of code before I checked for modified rows:

this.BindingContext[unitDataDT].EndCurrentEdit();

then DataTable modifiedRows = unitDataDT.GetChanges(DataRowState.Modified);

Lenny