How to get modified rows from a datagrid , when the changes are made on the editable datagrid itself
I have a datagrid bound to a datatable , which has customized table style. I display the editable datagrid. I modify some rows ( say row 1, 5 and 6 ) on the datagrid from the interface.
Now I would like to get this set of modified rows in the program. Somehow followoing methods are not working for me ?
Method : 1
(objDRow.RowState = DataRowState.Modified)
Dim objDRow As DataRow
For Each objDRow In MyDataSet.Tables("MyTable").Rows
If (objDRow.RowState = DataRowState.Modified) Then
'get value of that modified cell
End If
Next
Method- 2
I tried to use dataview using
Dim dview As New DataView(MyDataSet.Tables("MyTable"))
dview.RowStateFilter = DataViewRowState.ModifiedOriginal
And then iterating through each row of view, thinking that I get modified rows here..but does not wrok
Method- 3
I tried to use following comarison
objDRow.Item(2, DataRowVersion.Original) <> objDRow.Item(2, DataRowVersion.Current)
not working.
But surprisingly if you change the row value through code : it marks the row as modified row.
for example objDRow.Item(2) = "xtz" <-------- i am changing the value here progrmmatically.
Now if I do
MsgBox(objDRow.RowState) then the state is modified ???
So the question is how do we detect mdofied rows ( or cells ) on datagrid rows when changes are made through visual interface, I mean directly from editing datagrid ??
Please if anyone knows let me know asap. Thanks.