Artform04
asked on
Recreating a dataset based on gridview
Hi guys,
I need to create a dataset that mimicks the data I have in a gridview. This is part of a custom sorting problem I am having.
So far i have the code below, but it doesnt return the data that I see on my gridview. Could someone please let me know how to copy the data??
Thanks in advance.
Phil
I need to create a dataset that mimicks the data I have in a gridview. This is part of a custom sorting problem I am having.
So far i have the code below, but it doesnt return the data that I see on my gridview. Could someone please let me know how to copy the data??
Thanks in advance.
Phil
Dim dsCurrent As New DataSet
dsCurrent.Tables.Add()
For i As Integer = 0 To GridView1.Columns.Count - 1
dsCurrent.Tables(0).Columns.Add()
Next
For Each r As UI.WebControls.GridViewRow In GridView1.Rows
dsCurrent.Tables(0).Rows.Add()
For i As Integer = 0 To r.Cells.Count - 1
dsCurrent.Tables(0).Rows(dsCurrent.Tables(0).Rows.Count - 1).Item(i) = r.DataItem(i)
Next
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER