【问题标题】:Changing a column value in whole rows in datatable更改数据表中整行的列值
【发布时间】:2014-01-28 18:13:12
【问题描述】:

我尝试更改数据表中所有行中的列值并在 datagridview 中显示数据表,但在 datagridview 中没有显示任何内容,这是我使用的源代码,请帮助我

      DataTable d = new DataTable();
      d = DataPortAction.GetCustomerHostById(CustomerId);
      foreach (DataRow ro in d.Rows)
      {
          DateTime dt1 = new DateTime();
          dt1 = Convert.ToDateTime(ro[2]);
         ro[2] = (PersianDate)dt1;

      }
      dataGridView1.DataSource = d;

【问题讨论】:

    标签: c# winforms datagridview datatable


    【解决方案1】:

    请在绑定到网格之前尝试调用。

    d.AcceptChanges();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-13
      • 2020-08-15
      • 1970-01-01
      相关资源
      最近更新 更多