asp.net datatable中行的复制

DataRow复制一行到另一个DataTable
下面两个方法是DataRow复制一行到另一个DataTable的,直接Add会出错“此行已属于另一个表”,其实以前就知道怎么做的,可每次要用到的时候还是犯糊涂,这次把它们记下来。 1.用DataRow.ItemArray DataTable t=new DataTable(); DataRow r=t.NewRow(); r.ItemArray=oldRow.ItemArray; t.Rows.Add(r);
2.用DataTable.ImportRow() t.ImportRow(oldRow);
posted @ 2011-11-16 10:25  指尖流淌  阅读(327)  评论(0编辑  收藏  举报