copy filtered datarow to datatable's datarow

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SunshineInTheRain
    New Member
    • Jan 2008
    • 14

    #1

    copy filtered datarow to datatable's datarow

    Code:
     Dim dtUn As DataTable
            dtUn= New DataTable
            dtUn = BindICUN()
            Dim i As Integer
            Dim irow As DataRow
            Dim mailBody As String = ""
    
            Dim myRow As DataRow
            Dim rowSet As DataRow()
            rowSet = dtUn.Select("Distinct Member_id is not null")
    
            Dim dt As DataTable
            dt = New DataTable
            dt.Columns.Add(New DataColumn("Trans_ID", GetType(Integer)))
    
            Dim dr As DataRow
            'dr("Trans_ID") = myRow("Trans_ID")
            For Each myRow In rowSet
                dr = dt.NewRow()
                dr.ItemArray = myRow.ItemArray()
                dt.Rows.Add(dr)
            Next
          return dt
    what wrong with my code above? I just want to copy filtered record to another datatable.

    Actually what i wan is bind the filtered record to datagridview, since after filter I don't how to bind using the datarow, so i copy datarow to rows in another datatable so can bind. Any better idea by giving sample code? or who can guide me on how to modify code above? Any help much appreciated. Thanks.
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    You need to use the .ImportRow method:

    Comment

    Working...