locked
How to Copy some rows from the source Datatable to DESTINATION DataTable using datarow import method C# sample RRS feed

  • Question

  • User-757609608 posted

    How to Copy some rows from the

    sourceDatatable to destinationDataTable using Datarow import method C# sample.

    Monday, November 14, 2011 12:27 AM

Answers

  • User1074791864 posted

    Hi,

    Please find the below code to import source datatable rows to target.

    DataTable dtSource = new DataTable();

    DataTable dtTarget = new DataTable();

    dtTarget = dtSource.Clone();

    int rowcount = dtSource.Rows.Count;
    for (int i = 0; i <= rowcount ; ++i)

    {

    dtTarget.ImportRow(dtSource.Rows[i]);

    }

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 14, 2011 12:53 AM