Though there are methods for setting the RowState
property explicitly, like SetAdded
, SetModified
and Delete
, I think it's better to understand what exactly happens automatically.
If you need to set the RowState
to unchanged, then call AcceptChanges
on the row and go from there. If you need it to be in a modified state, and it's not currently, there's a good chance you should have called AcceptChanges
on the DataRow
or DataTable
somewhere else in the logic - this way when you make modifications to the row via code like:
row["field"] = "New Value";
it changes the RowState
to Modified
but now it also has a baseline, the Original
row state, because you had accepted the changes previously.
My point here is that, yes, you can set the RowState
explicitly with a few of those methods, but I feel like you may just need to work with the ADO.NET interface a bit more like it was intended.
Rows[0].SetAdded()
andRows[0].SetModified()
andRows[0].Delete()