I am using GridView in my application for populating datas.
Is there any easy way to copy a gridview to datatable ?
Actually, in my GridView one of the control is textbox.
So I can edit that control at any time… What I need is on the button click whatever changes I made in GridView has to copy in one datatable…
I did this using the code,
dt = CType(Session('tempTable'), DataTable) i = 0 For Each rows As GridViewRow In Grid1.Rows Dim txt As TextBox txt = CType(rows.FindControl('txt'), TextBox) dt.Rows(i)(1) = txt.Text i = i + 1 Next
Here I am traversing through grid with the help of ‘for each’ loop.
I am worrying whether it effects performance?
Can you please tel me any other simple method to copy a GridView to a datatable
html page look like,
on page load,
conn = New OleDb.OleDbConnection(‘Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D:\GDD_Work\Employee.mdb’)
on add button click,
If Session(‘blnFlag’) = False Then Session(‘blnFlag’) = True Else getFooter() End If
on save button click,
Dim intOldCount As Integer Dim intNewCount As Integer Dim dt As New DataTable Dim strQuery As String intOldCount = CType(Session(‘intOldCount’), Integer) If Session(‘blnFlag’) = True Then
im using one function like,
Public Function getFooter() Dim tx1 As TextBox Dim tx2 As TextBox Dim drp As DropDownList tx1 = CType(Grid1.FooterRow.FindControl(‘txt1’), TextBox) tx2 = CType(Grid1.FooterRow.FindControl(‘txt2’), TextBox) drp = CType(Grid1.FooterRow.FindControl(‘Drop1’), DropDownList)