DataSet newds = new DataSet();
newds = dsUser.Clone();
int[] idarray; if(ViewState["DataIdTable"]!=null)
{
idarray=(int[])ViewState["DataIdTable"]; DataRow[] row;
for (int i = 0; i < idarray.Length; i++)
{
row=dsUser.Tables[0].Select("id="+idarray[i]+"");
newds.Tables[0].Rows.Add((object[])row);
}
GridView2.DataSource = newds;
GridView2.DataBind();
}
无法将类型为“System.Data.DataRow”的对象强制转换为类型“System.IConvertible”。不能在 Id 列中存储 <System.Data.DataRow>。所需类型是 Int32。
private DataTable GetNewDataTable(DataTable dt,string condition)
{
DataTable newdt = new DataTable();
newdt=dt.Clone();
DataRow[] dr = dt.Select(condition);
for(int i=0;i<dr.Length;i++)
{
newdt.ImportRow((DataRow)dr[i]);
}
return newdt;
}