Detecting when a row has changed in a dataset / datatable

I am trying to add some additional protocols to my C # winforms application. I have a few data forms bound data that is managed by all the database stuff using a binding source and some typed datasets / adapters.

With this setting it is difficult to tell when something has changed, I would need to manage each field and keep it the same value. Is there a way that I can connect to the dataset and tell when something has changed? I know datarow has a RowState enum, would that be a good place to start? I looked into the original DataMemberChanged event but it never fired like this ...

+2


source to share


3 answers


You can use the RowChanged , RowChanging event , or any of the other events raised by the DataTable.



+4


source


To get the original value of the updated Data value, you can do this:



<DataTableRow>[<DataColumn>, DataRowVersion.Original]

      

+11


source


See DataSet.GetChanges Method to see what has changed . This example shows you how to get the changes and go through them. I also have an old example here that uses a DataTable and shows how to do a post-merge comparison. It checks the RowState and shows the changed values, etc. It's at the bottom of the page and it's in VB as the OP was using this and not C #. Now I'm on my way, so I can't provide an equivalent translation, but using some helpful methods should be pretty easy.

+5


source







All Articles