JOE SKEET
JOE SKEET

Reputation: 8108

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

i am currently doing this:

    for (int i = 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?

Upvotes: 1

Views: 6477

Answers (1)

k3b
k3b

Reputation: 14755

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]);

Upvotes: 5

Related Questions