DataTable Table = new DataTable();
DataRow row;
try
{
row = Value.NewRow();
for (int i = 0; i < Value.Rows.Count; i++)
{
TableNm = new DataView(DB.Tables[1]);
TableNm.RowFilter = "name = " + "'" +""+Value.Rows[i][0].ToString()+"" + "'" + "";
row[i] = (TableNm.ToTable()).Rows;
}
Table.Rows.Add(row);
对于以上我试图过滤多个值并在数据表中绑定或添加行但是它没有对for循环中的dataview rowfilter有任何建议 每个Rowfilter每次只返回一行
答案 0 :(得分:0)
这是一个真正的问题,你可以先添加动态列,而不是尝试row.add(行项目arry)的行.add()
就像
一样 DataTable Table = new DataTable();
DataRow row;
try
{
//Add column here
row = Value.NewRow();
for (int i = 0; i < Value.Rows.Count; i++)
{
TableNm = new DataView(DB.Tables[1]);
TableNm.RowFilter = "name = " + "'" +""+Value.Rows[i][0].ToString()+"" + "'" + "";
row[i] = (TableNm.ToTable()).Rows;
}
Table.Rows.Add(row.ItemArray);