How can I get a specific version of a dataset row?

≯℡__Kan透↙ 提交于 2019-12-24 03:54:30

问题


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:


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.



来源:https://stackoverflow.com/questions/1050837/how-can-i-get-a-specific-version-of-a-dataset-row

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!