编程语言
首页 > 编程语言> > c# DataRow[]转Datatable

c# DataRow[]转Datatable

作者:互联网

方法一:

Datatable dt=new Datatable();

//添加列和数据(代码省略)

DataRow[] drs = dt.Select("DeviceID='123'");
_dt = drs.CopyToDataTable();
dgvList.DataSource = _dt;

方法二:

DataRow[] dr = dt.Select("DeviceID='"+DeviceID+"'");
DataTable d = dt.Clone();
for (int i=0;i<dr.Length;i++)
{
d.ImportRow(dr[i]);
}

标签:c#,drs,DataRow,DeviceID,dt,dr,Datatable
来源: https://www.cnblogs.com/innershare/p/10996931.html