方法一:
类中写好一个构建的datetable;
DataTable dt_CustomerCredit_one = Common.CreateCGOACustomerCreditDataTable();
Datatable dt=new Datatable();
//添加列和数据(代码省略)
DataRow[] drs = dt.Select("DeviceID=‘123‘");
_dt = drs.CopyToDataTable();
可数据绑定
dgvList.DataSource = _dt;
也可以做数据循环输出
for (int i = 0; i < _dt.Rows.Count; i++)
{
DataRow ndr = dt_CustomerCredit_one.NewRow();
ndr["GUID"] = Guid.NewGuid().ToString();
ndr["PositionName"] = _dt_one.Rows[i]["JobTitle"].ToString();
}
方法二:
DataRow[] dr = dt.Select("DeviceID=‘"+DeviceID+"‘");
DataTable d = dt.Clone();
for (int i=0;i<dr.Length;i++)
{
d.ImportRow(dr[i]);
}