tags:

views:

306

answers:

1

using a dataset,each row has a method called hasVersion() which implies to me it keeps a copy of the original and current versions of that row. How can I get one of the original row values?

I'd imagine it's possible to call reject changes on that row and then check the value, but I'd rather not lose the changes, just read the value(s).

+1  A: 

If you are looking at a particular row, you can get a particular version of the row's values through the DataRowVersion enumeration thru one of the overloads, e.g.

SomeDataRow[0, DataRowVersion.Original] //by index
SomeDataRow["ColumnName", DataRowVersion.Original] //by column name

Along with that, you might want to use the GetChanges() method on the datatable. Pass in a DataRowState (in your case, DataRowState.Modified), then use the above to get the original value of any rows that have changed.

joshua.ewer
This looks like it should work terrific, I'll have to test it.when you put a strongly typed datatable as the datasource of a datagridview are changes on the datagridview reflected in the dataset?
Maslow
Yes. Actually, that's intrinsic to all DataSet/DataTables, not just strongly-typed. A DataSet contains a diffgram that will track changes. Assuming you have a DataGridView bound to a DataTable, then whatever DataRows get changed will then have a DataRowState of "Modified."
joshua.ewer