我可以知道我的数据表是否已编辑 [英] Can I know If My datatable Edited
本文介绍了我可以知道我的数据表是否已编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数据表,可以绑定到我的表单,所以它也绑定到表单的控件
现在,我是否可以知道数据表是否由用户编辑(在表单的控制范围内)..?
任何人都可以帮助我..?
谢谢Advanced
i have a datatabe which i bind to my Form So it also bind to the Control of the form
and for now can i Know if the datatable is Edited by the user (within the control of the Form) ..?
any one can help me please ..?
thanks in advanced
推荐答案
您可以使用 DataTable .GetChanges [^ ]并检查它是否返回null.
或者,您可以遍历DataTable
中的行并检查 DataRow.RowState [^ ]属性,使用linq看起来像这样
You can use DataTable.GetChanges[^] and check if it returns null or not.
Or you can loop over the rows in theDataTable
and check the DataRow.RowState[^] property, with linq it would look something like this
bool hasChanges = myDataTable.Rows.Cast<DataRow>()
.Any(r => r.RowState != DataRowState.Unchanged);
这篇关于我可以知道我的数据表是否已编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文