Merge 2 DataTables and store in a new one

后端 未结 5 1882
别那么骄傲
别那么骄傲 2020-11-28 11:14

If I have 2 DataTables (dtOne and dtTwo) and I want to merge them and put them in another DataTable (dtAll). How can I do this in C#? I tried the Merge statement on the da

5条回答
  •  醉话见心
    2020-11-28 11:35

    DataTable dtAll = new DataTable();
    DataTable dt= new DataTable();
    foreach (int id in lst)
    {
        dt.Merge(GetDataTableByID(id)); // Get Data Methode return DataTable
    }
    dtAll = dt;
    

提交回复
热议问题