This Row already belongs to another table error when trying to add rows?

后端 未结 7 1514
闹比i
闹比i 2020-11-28 02:58

I have a DataTable which has some rows and I am using the select to filter the rows to get a collection of DataRows which I then loop through using foreach and add it to ano

7条回答
  •  时光取名叫无心
    2020-11-28 03:20

    Try this:

    DataTable dt = (DataTable)Session["dtAllOrders"];
    DataTable dtSpecificOrders = dt.Clone();
    
    DataRow[] orderRows = dt.Select("CustomerID = 2");
    
    foreach (DataRow dr in orderRows)
    {
        dtSpecificOrders.ImportRow(dr);
    }
    

提交回复
热议问题