Datatable Modified属性中缺少行 [英] Missing Row in Datatable Modified property

查看:255
本文介绍了Datatable Modified属性中缺少行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新绑定到我的 DataTable DataGridView 中列出的第一条记录。当我运行保存过程时,我将通过以下代码行获取所有已修改的记录:

Updating the first record listed in my DataGridView that is bound to my DataTable. When I run Save process I run through this line of code to get all records that have been modified:

DataTable modifiedRows = unitDataDT.GetChanges(DataRowState.Modified);

如果我更改了 DataGridView 我的ModifyRows DataTable 为Null。
如果我更改以下任何记录,它们都在我的ModifyRows DataTable 中。

我尝试更改<$ c中的其他记录$ c> DataGridView
,然后更改第一条记录,然后运行保存过程,仍然....其他记录在那里,而第一条记录却没有.....

If I have changed the first record in my DataGridView my modifiedRows DataTable is Null. If I change any of the following records they are in my modifiedRows DataTable.
I have tried changing other records in my DataGridView first and then changing the first record then running the Save process and still....other records are there and the first record is not.....

还....我检查了unitDataDT并进行了更改。
我对datagridview进行了排序,以尝试更新其他记录,但是它仍然没有将更改添加到ModifyedRows Datatable中。...因此,它似乎不适用于DataGridView中列出的第一条记录。

Also....I checked the unitDataDT and it has the change. I sorted the datagridview to try and update a different record and it still did not add the change to the modifiedRows Datatable....so it seems to not work for the first record listed in the DataGridView.

有什么想法吗?

推荐答案

发现了我的问题...。虽然不确定为什么它只影响显示的第一行。
在检查修改后的行之前,我添加了以下代码行:

Found my issue....although not sure why it just affected the first row displayed. I added this line of code before I checked for modified rows:

this.BindingContext [unitDataDT] .EndCurrentEdit();

this.BindingContext[unitDataDT].EndCurrentEdit();

然后
DataTable ModifyRows = unitDataDT.GetChanges(DataRowState.Modified);

then DataTable modifiedRows = unitDataDT.GetChanges(DataRowState.Modified);

这篇关于Datatable Modified属性中缺少行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆