How can I copy specific rows from DataTable to another Datatable | Datatable assign one row to another table

Datatable assign one row to another table
How can I copy specific rows from DataTable to another Datable.

Solution:
You can use ImportRow method to copy Row from DataTable to DataTable with the same schema

Example:
VB.net
For i As Integer = 0 To dttemp.Rows.Count - 1
  DtGetData.Rows.Clear()
  DtGetData = dttemp.Clone
  Dim dr = dttemp.Rows(i)
  DtGetData.ImportRow(dr)
Next
C#
var row = SourceTable.Rows[RowNum];
DestinationTable.ImportRow(row);

Post a Comment

0 Comments