Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class Class1
Inherits System.Web.UI.Page
Dim con As New SqlConnection
Dim s As String
Dim ds As New DataSet
Dim da As New SqlDataAdapter
Dim scb As New SqlCommandBuilder
Public grid As GridView
Public litHeader As Literal
Public WithEvents txtSearch As TextBox
' Public WithEvents txtSearch As DropDownList
'Public WithEvents txtSearch1 As TextBox
'Public WithEvents txtSearch2 As TextBox
'Public WithEvents txtSearch3 As TextBox
'Public WithEvents txtSearch4 As TextBox
'Public WithEvents txtSearch5 As TextBox
'Public WithEvents txtSearch6 As TextBox
Public f As String
Sub BulkEditGridView1_1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.Header Then
For i As Integer = 0 To (e.Row.Cells.Count - 1)
For z As Integer = 1 To (e.Row.Cells.Count - 1)
If i = z Then
txtSearch = New TextBox
txtSearch.ID = "txtname" & z
txtSearch.Width = 35
e.Row.Cells(z).Controls.Add(txtSearch)
End If
Next
Next
End If
'End If
End Sub
Public Function search(ByVal ds As DataSet, ByVal BulkEditGridView1_1 As GridView) As DataSet
Dim s As String = CType(BulkEditGridView1_1.HeaderRow.FindControl("txtname1"), System.Web.UI.WebControls.TextBox).Text
'dim s as = CType(BulkEditGridView1_1.HeaderRow.Controls(0), TextBox).Text
Dim r As String = CType(BulkEditGridView1_1.HeaderRow.FindControl("txtname2"), System.Web.UI.WebControls.TextBox).Text
Dim n As String = CType(BulkEditGridView1_1.HeaderRow.FindControl("txtname3"), System.Web.UI.WebControls.TextBox).Text
Dim str_s, str_r, str_n As String
Dim dt As DataTable
Dim dr As DataRow
Dim dc As DataColumn
'dc=new DataColumn("
' dr = New DataRow()
'==============
Dim Table1 As DataTable
Table1 = New DataTable()
'creating a table named Customers
' Dim Row1, Row2, Row3 As DataRow
'declaring three rows for the table
'Try
Dim Name As DataColumn = New DataColumn("name")
' 'declaring a column named Name
' Name.DataType = System.Type.GetType("System.String")
' 'setting the datatype for the column
' Table1.Columns.Add(Name)
' 'adding the column to table
' Dim Product As DataColumn = New DataColumn("Product")
' Product.DataType = System.Type.GetType("System.String")
' Table1.Columns.Add(Product)
' Dim Location As DataColumn = New DataColumn("Location")
' Location.DataType = System.Type.GetType("System.String")
' Table1.Columns.Add(Location)
'Row1 = Table1.NewRow()
''declaring a new row
'Row1.Item("Name") = "Reddy"
''filling the row with values. Item property is used to set the field value.
'Row1.Item("Product") = "Notebook"
''filling the row with values. adding a product
'Row1.Item("Location") = "Sydney"
''filling the row with values. adding a location
'Table1.Rows.Add(Row1)
' 'adding the completed row to the table
' Row2 = Table1.NewRow()
' Row2.Item("Name") = "Bella"
' Row2.Item("Product") = "Desktop"
' Row2.Item("Location") = "Adelaide"
' Table1.Rows.Add(Row2)
' Row3 = Table1.NewRow()
' Row3.Item("Name") = "Adam"
' Row3.Item("Product") = "PDA"
' Row3.Item("Location") = "Brisbane"
' Table1.Rows.Add(Row3)
'Catch
'End Try
'Dim ds As New DataSet()
'ds = New DataSet()
''creating a dataset
'ds.Tables.Add(Table1)
'gv.DataSource = ds
'gv.DataBind()
For i As Integer = 0 To ds.Tables(0).Columns.Count - 1
'Dim str As String = ds.Tables(0).Columns(i).ColumnName
Dim col As DataColumn
col = New DataColumn
col.ColumnName = ds.Tables(0).Columns(i).ColumnName
col.DataType = GetType(System.String)
Table1.Columns.Add(col)
'Table1.Columns(i).ColumnName = ds.Tables(0).Columns(i).ColumnName
Next
'Dim str As String = ds.Tables(0).Columns(0).ColumnName
'============
Dim dr1 As DataRow
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
str_s = ds.Tables(0).Rows(i).Item(0).ToString
str_r = ds.Tables(0).Rows(i).Item(1).ToString
str_n = ds.Tables(0).Rows(i).Item(2).ToString
dr1 = Table1.NewRow()
If str_s.StartsWith(s) Then
'dr1 = New TableRow
dr1.Item(0) = ds.Tables(0).Rows(i).Item(0).ToString
dr1.Item(1) = ds.Tables(0).Rows(i).Item(1).ToString
dr1.Item(2) = ds.Tables(0).Rows(i).Item(2).ToString
' Table1.Rows.Add(ds.Tables(0).Rows(i))
Table1.Rows.Add(dr1)
End If
'If str_r.StartsWith(r) Then
'dt.Rows.Add(ds.Tables(0).Rows(i))
'End If
Next
Dim ds1 As New DataSet
ds.Tables.Add(Table1)
Return ds1
' binddata(dt, BulkEditGridView1_1)
' s = "SELECT Id,Label,Textbox FROM textboxtable where Id like '" & s & "%' and label like '" & r & "%' and Textbox like '" & n & "%'"
'Return s
End Function
Public Sub binddata(ByVal dt As DataSet, ByVal grid As GridView)
'da = New SqlDataAdapter(s, con)
'scb = New SqlCommandBuilder(da)
'ds = New DataSet
'da.Fill(ds)
dt = Me.search(ds, grid)
grid.DataSource = dt
grid.DataBind()
End Sub
End Class
Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class Class1
Inherits System.Web.UI.Page
Dim con As New SqlConnection
Dim s As String
Dim ds As New DataSet
Dim da As New SqlDataAdapter
Dim scb As New SqlCommandBuilder
Public grid As GridView
Public litHeader As Literal
Public WithEvents txtSearch As TextBox
' Public WithEvents txtSearch As DropDownList
'Public WithEvents txtSearch1 As TextBox
'Public WithEvents txtSearch2 As TextBox
'Public WithEvents txtSearch3 As TextBox
'Public WithEvents txtSearch4 As TextBox
'Public WithEvents txtSearch5 As TextBox
'Public WithEvents txtSearch6 As TextBox
Public f As String
Sub BulkEditGridView1_1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.Header Then
For i As Integer = 0 To (e.Row.Cells.Count - 1)
For z As Integer = 1 To (e.Row.Cells.Count - 1)
If i = z Then
txtSearch = New TextBox
txtSearch.ID = "txtname" & z
txtSearch.Width = 35
e.Row.Cells(z).Controls.Add(txtSearch)
End If
Next
Next
End If
'End If
End Sub
Public Function search(ByVal ds As DataSet, ByVal BulkEditGridView1_1 As GridView) As DataSet
Dim s As String = CType(BulkEditGridView1_1.HeaderRow.FindControl("txtname1"), System.Web.UI.WebControls.TextBox).Text
'dim s as = CType(BulkEditGridView1_1.HeaderRow.Controls(0), TextBox).Text
Dim r As String = CType(BulkEditGridView1_1.HeaderRow.FindControl("txtname2"), System.Web.UI.WebControls.TextBox).Text
Dim n As String = CType(BulkEditGridView1_1.HeaderRow.FindControl("txtname3"), System.Web.UI.WebControls.TextBox).Text
Dim str_s, str_r, str_n As String
Dim dt As DataTable
Dim dr As DataRow
Dim dc As DataColumn
'dc=new DataColumn("
' dr = New DataRow()
'==============
Dim Table1 As DataTable
Table1 = New DataTable()
'creating a table named Customers
' Dim Row1, Row2, Row3 As DataRow
'declaring three rows for the table
'Try
Dim Name As DataColumn = New DataColumn("name")
' 'declaring a column named Name
' Name.DataType = System.Type.GetType("System.String")
' 'setting the datatype for the column
' Table1.Columns.Add(Name)
' 'adding the column to table
' Dim Product As DataColumn = New DataColumn("Product")
' Product.DataType = System.Type.GetType("System.String")
' Table1.Columns.Add(Product)
' Dim Location As DataColumn = New DataColumn("Location")
' Location.DataType = System.Type.GetType("System.String")
' Table1.Columns.Add(Location)
'Row1 = Table1.NewRow()
''declaring a new row
'Row1.Item("Name") = "Reddy"
''filling the row with values. Item property is used to set the field value.
'Row1.Item("Product") = "Notebook"
''filling the row with values. adding a product
'Row1.Item("Location") = "Sydney"
''filling the row with values. adding a location
'Table1.Rows.Add(Row1)
' 'adding the completed row to the table
' Row2 = Table1.NewRow()
' Row2.Item("Name") = "Bella"
' Row2.Item("Product") = "Desktop"
' Row2.Item("Location") = "Adelaide"
' Table1.Rows.Add(Row2)
' Row3 = Table1.NewRow()
' Row3.Item("Name") = "Adam"
' Row3.Item("Product") = "PDA"
' Row3.Item("Location") = "Brisbane"
' Table1.Rows.Add(Row3)
'Catch
'End Try
'Dim ds As New DataSet()
'ds = New DataSet()
''creating a dataset
'ds.Tables.Add(Table1)
'gv.DataSource = ds
'gv.DataBind()
For i As Integer = 0 To ds.Tables(0).Columns.Count - 1
'Dim str As String = ds.Tables(0).Columns(i).ColumnName
Dim col As DataColumn
col = New DataColumn
col.ColumnName = ds.Tables(0).Columns(i).ColumnName
col.DataType = GetType(System.String)
Table1.Columns.Add(col)
'Table1.Columns(i).ColumnName = ds.Tables(0).Columns(i).ColumnName
Next
'Dim str As String = ds.Tables(0).Columns(0).ColumnName
'============
Dim dr1 As DataRow
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
str_s = ds.Tables(0).Rows(i).Item(0).ToString
str_r = ds.Tables(0).Rows(i).Item(1).ToString
str_n = ds.Tables(0).Rows(i).Item(2).ToString
dr1 = Table1.NewRow()
If str_s.StartsWith(s) Then
'dr1 = New TableRow
dr1.Item(0) = ds.Tables(0).Rows(i).Item(0).ToString
dr1.Item(1) = ds.Tables(0).Rows(i).Item(1).ToString
dr1.Item(2) = ds.Tables(0).Rows(i).Item(2).ToString
' Table1.Rows.Add(ds.Tables(0).Rows(i))
Table1.Rows.Add(dr1)
End If
'If str_r.StartsWith(r) Then
'dt.Rows.Add(ds.Tables(0).Rows(i))
'End If
Next
Dim ds1 As New DataSet
ds.Tables.Add(Table1)
Return ds1
' binddata(dt, BulkEditGridView1_1)
' s = "SELECT Id,Label,Textbox FROM textboxtable where Id like '" & s & "%' and label like '" & r & "%' and Textbox like '" & n & "%'"
'Return s
End Function
Public Sub binddata(ByVal dt As DataSet, ByVal grid As GridView)
'da = New SqlDataAdapter(s, con)
'scb = New SqlCommandBuilder(da)
'ds = New DataSet
'da.Fill(ds)
dt = Me.search(ds, grid)
grid.DataSource = dt
grid.DataBind()
End Sub
End Class
the code is not working the ...when i click the search absolutely nothing happens... course it shows error on the line where i am adding the dr1 to the table1