This Row already belongs to another table error when trying to add rows?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 another DataTable, but it is giving me the error "This Row already belongs to another table". Here is the code: DataTable dt = (DataTable)Session["dtAllOrders"]; DataTable dtSpecificOrders = new DataTable(); DataRow[] orderRows = dt.Select("CustomerID = 2"); foreach (DataRow dr in orderRows) { dtSpecificOrders.Rows.Add(dr); //Error thrown here. } 回答1: You need to create a