开发者

add a row to a datatable from a row in a different datatable

开发者 https://www.devze.com 2023-02-01 04:32 出处:网络
i am currently doing this: for (int i = 开发者_C百科0; i < 15; i++) { dt_final.Rows.Add(dt.Rows[i]);

i am currently doing this:

    for (int i = 开发者_C百科0; i < 15; i++)
    {
        dt_final.Rows.Add(dt.Rows[i]);
    }

but i am getting an error that this row belongs to another table. how do i import this row to dt_final table?


you can only add rows that where created from the DataTable (ie throug NewRow). But you can import a row from a different table

 dt_final.ImportRow(dt.Rows[i]);
0

精彩评论

暂无评论...
验证码 换一张
取 消