Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert dataview rows into a datatable

Status
Not open for further replies.

logi2000

Programmer
Jun 17, 2003
221
CR
i want to insert the filter rows of a dataview inside a data table. how can i do that ?
 
I presume you mean a seperate table to the one on which your view is based. The following will do this assuming the 2nd table is the same structure as the one which the view is based upon.
Code:
'dv=Your Dataview, newdt=Your New Table
For Each drv As DataRowView In dv
     Dim dr As DataRow = drv.Row
     newdt.Rows.Add(dr.ItemArray)
Next
If your tables are of a different structure, you will have to pick the values from the dr datarow, create a new row for your new datatable and assign the values, before finally adding the new row to the table.
Code:
dim newrow as datarow
newrow = newdt.newrow
newrow("Field1")="TEXT"
newrow("Field2")=20
newdt.rows.add(newrow)




Sweep
...if it works dont mess with it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top