Adding DataTable Rows To another DataTable

Discussion in 'ASP .Net' started by J. Babe, Aug 15, 2003.

  1. J. Babe

    J. Babe Guest

    I was wondering how to add the first 20 rows from one datatable to
    another datatable without getting the error:
    This row already belongs to another table
     
    J. Babe, Aug 15, 2003
    #1
    1. Advertising

  2. You need to "clone" the DataRow for the other table. DataRow doesn't
    implement ICloneable, so you will need to create a loop that creates a new
    row in the second DataTable, and copies the data contained in the columns of
    the first DataTables row to the new row created for the second DataTable,
    and then adds the new DataRow to the Rows Collection of the second
    DataTable.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    http://www.takempis.com
    Neither a follower nor a lender be.

    "J. Babe" <> wrote in message
    news:...
    > I was wondering how to add the first 20 rows from one datatable to
    > another datatable without getting the error:
    > This row already belongs to another table
     
    Kevin Spencer, Aug 15, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fredrik Rodin

    Sort a datatable and create a new datatable

    Fredrik Rodin, Feb 16, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    9,116
    paul.mariotti
    Sep 28, 2007
  2. =?Utf-8?B?Qmx1ZWZsb3dlcg==?=

    Casting DataTable to class inherit from DataTable

    =?Utf-8?B?Qmx1ZWZsb3dlcg==?=, Apr 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,038
    =?Utf-8?B?Qmx1ZWZsb3dlcg==?=
    Apr 2, 2004
  3. jg
    Replies:
    1
    Views:
    758
    =?Utf-8?B?U2hhaWxlc2ggSmFubnU=?=
    Aug 17, 2004
  4. Ersin Gençtürk
    Replies:
    1
    Views:
    3,554
    Ersin Gençtürk
    Oct 6, 2004
  5. Replies:
    0
    Views:
    446
Loading...

Share This Page