Connecting Tech Pros Worldwide Forums | Help | Site Map

copy filtered datarow to datatable's datarow

Newbie
 
Join Date: Jan 2008
Posts: 14
#1: Aug 13 '08
Expand|Select|Wrap|Line Numbers
  1.  Dim dtUn As DataTable
  2.         dtUn= New DataTable
  3.         dtUn = BindICUN()
  4.         Dim i As Integer
  5.         Dim irow As DataRow
  6.         Dim mailBody As String = ""
  7.  
  8.         Dim myRow As DataRow
  9.         Dim rowSet As DataRow()
  10.         rowSet = dtUn.Select("Distinct Member_id is not null")
  11.  
  12.         Dim dt As DataTable
  13.         dt = New DataTable
  14.         dt.Columns.Add(New DataColumn("Trans_ID", GetType(Integer)))
  15.  
  16.         Dim dr As DataRow
  17.         'dr("Trans_ID") = myRow("Trans_ID")
  18.         For Each myRow In rowSet
  19.             dr = dt.NewRow()
  20.             dr.ItemArray = myRow.ItemArray()
  21.             dt.Rows.Add(dr)
  22.         Next
  23.       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.



insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,608
#2: Aug 13 '08

re: copy filtered datarow to datatable's datarow


You need to use the .ImportRow method:
http://support.microsoft.com/kb/308909
Reply