【问题标题】:Datatable Getchanges not working数据表Getchanges不起作用
【发布时间】:2011-04-13 13:39:16
【问题描述】:

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

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

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

我在这里错过了什么吗?

【问题讨论】:

    标签: ado.net datagridview datatable


    【解决方案1】:

    您在 DataTable 上使用 GetChanges(),而不是 DataSet

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

    【讨论】:

      猜你喜欢
      • 2015-07-15
      • 2012-08-03
      • 2023-03-20
      • 2012-11-19
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      • 2018-03-28
      • 2014-07-26
      相关资源
      最近更新 更多