You must Sign In to post a response.
  • Category: .NET

    C# . net+ datatable.importrow

    hi,
    i wnat to impoet rows from a datatable but not affecting tae datatable.
    can i perform datarow copy or clone?

    thanks
  • #391146
    Hi,


    Do you want to copy a row from one table to another table?

    Regards
    JK

    Thanks & Regards
    D.Jeya Kumar(JK)

  • #391151
    Hi,

    Use ImportRow to import rows from another table

    ** You can use DataTable.Load method to load data from a IDataReader
    object, which can be created through DataTable.CreateDataReader

    Also when load data into datatable, you should call BeginLoadData,
    EndLoadData so as to turn off event notification(improve performance

    Regards

    VIJI RAJKUMAR
    Pls rate my Answer if it was supportive
    http://vijirajkumar.blogspot.com

  • #391155
    Hi,


    check the below sample code. it might help you or give you an idea to use the import row


    //Fill the datatable before using the sample code
    datatable dtNodeGridLoadFiles = new datatable();
    foreach (DataRow drOnGrid in dtOnGrid.Rows) {
    if ((drOnGrid != null)) {
    if (drOnGrid .Length > 0) {
    dtNodeGridLoadFiles.ImportRow(drOnGrid);
    }
    }
    }



    Regards
    JK

    Thanks & Regards
    D.Jeya Kumar(JK)

  • #391165
    hi,
    Thanks for yur reply. but . in this way the row is imported form the datatable . while there is no datarow in the original datatable how can i solve the problem .

    i need to copy datatable with same data and structure but when i make change in copy there is change in original datatable. how can i copy datatble in the way thet oriiginal and copy doesnot get affected by the changes in other.

  • #391250
    DataTable dtNew = new DataTable();
    dtNew.Merge(dtOrginal);

    if u make any chnages in dtNew table, it will not effect to the dtOrginal.

    Regards
    Raaj


This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.