数据表Getchanges不起作用 [英] Datatable Getchanges not working

查看:160
本文介绍了数据表Getchanges不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据表,该数据表已绑定到我的C#winforms应用程序中的DataGridView。

I have a datatable which is bound to a DataGridView in my C# winforms app.

我想仅将那些已更改的行传递到服务器端/由用户在数据网格中更新。

I want to pass datatable to the server side with only those rows which are changed/updated by the user in the datagrid.

但是dataTable.GetChanges()返回我所有的行,而不仅仅是返回更改过的行。

But dataTable.GetChanges() is returning me all the rows instead of just the changed ones.

我在这里错过了什么吗?

Am I missing something over here?

推荐答案

您使用了 GetChanges() DataTable 上的strong>,而不是 DataSet

You use GetChanges() on DataTable, not DataSet.

DataTable dtChanges = ds.Tables["DataTable"].GetChanges();

if ( dtChanges != null)
{
    foreach (DataRow dr in dtChanges.Rows)
    {
        MessageBox.Show("Changes: " + dr["DataStr"]);
    }
}

这篇关于数据表Getchanges不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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