Imports System
Imports System.Data
Imports System.Data.SqlClient
Partial Class Default2
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
Dim dt As New DataTable
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
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
con = New SqlConnection("server=DCPLDC;user id=sa;password=crorepathy;database=Testing")
con.Open()
s = "SELECT Id,Label,Textbox FROM textboxtable"
da = New SqlDataAdapter(s, con)
ds = New DataSet
scb = New SqlCommandBuilder(da)
da.Fill(ds)
ds.Tables.Add(dt)
dt = New DataTable("textboxtable")
BulkEditGridView1_2.DataSource = ds.Tables(0)
BulkEditGridView1_2.DataBind()
con.Close()
End Sub
Sub binddata()
s = "SELECT Id,Label,Textbox FROM textboxtable"
da = New SqlDataAdapter(s, con)
ds = New DataSet
scb = New SqlCommandBuilder(da)
da.Fill(ds)
ds.Tables.Add(dt)
dt = New DataTable("textboxtable")
BulkEditGridView1_1.DataSource = ds.Tables(0)
BulkEditGridView1_1.DataBind()
End Sub
Protected Sub BulkEditGridView1_1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles BulkEditGridView1_1.RowCreated
If e.Row.RowType = DataControlRowType.Header Then
Dim litHeader As Literal
Dim litHeader1 As Literal
Dim txtSearch As TextBox
' loop through each cell
For i As Integer = 0 To (e.Row.Cells.Count - 1)
If i = 1 Then
litHeader = New Literal
txtSearch = New TextBox
'GridView1.FindControl(txtSearch), = New TextBox
' Dim txt1 As TextBox = CType(GridView1.FindControl("textsearch"), TextBox)
With txtSearch
'.Text = "fdfdsfd"
'.MaxLength = 10
.Width = 35
'.Text = "rere"
.ID = "txtname1"
End With
' get the current header text
litHeader.Text = e.Row.Cells(1).Text & "<br />"
' add the header text plus a new textbox
e.Row.Cells(1).Controls.Add(litHeader)
e.Row.Cells(1).Controls.Add(txtSearch)
End If
If i = 2 Then
litHeader1 = New Literal
txtSearch1 = New TextBox
With txtSearch1
'.Text = "fdfdsfd"
.Width = 75
.ID = "txtname2"
End With
' get the current header text
litHeader1.Text = e.Row.Cells(2).Text & "<br />"
' add the header text plus a new textbox
e.Row.Cells(2).Controls.Add(litHeader1)
e.Row.Cells(2).Controls.Add(txtSearch1)
End If
If i = 3 Then
litHeader = New Literal
txtSearch2 = New TextBox
With txtSearch2
'.Text = "fdfdsfd"
.Width = 75
.ID = "txtname3"
End With
litHeader.Text = e.Row.Cells(3).Text & "<br />"
e.Row.Cells(3).Controls.Add(litHeader)
e.Row.Cells(3).Controls.Add(txtSearch2)
End If
If i = 4 Then
litHeader = New Literal
txtSearch3 = New TextBox
With txtSearch3
'.Text = "fdfdsfd"
.Width = 75
.ID = "txtname4"
End With
' get the current header text
litHeader.Text = e.Row.Cells(4).Text & "<br />"
' add the header text plus a new textbox
e.Row.Cells(4).Controls.Add(litHeader)
e.Row.Cells(4).Controls.Add(txtSearch3)
End If
If i = 5 Then
litHeader = New Literal
txtSearch4 = New TextBox
With txtSearch4
'.Text = "fdfdsfd"
.Width = 75
.ID = "txtname5"
End With
' get the current header text
litHeader.Text = e.Row.Cells(5).Text & "<br />"
' add the header text plus a new textbox
e.Row.Cells(5).Controls.Add(litHeader)
e.Row.Cells(5).Controls.Add(txtSearch4)
End If
If i = 6 Then
litHeader = New Literal
txtSearch5 = New TextBox
With txtSearch5
'.Text = "fdfdsfd"
.Width = 75
.ID = "txtname6"
End With
' get the current header text
litHeader.Text = e.Row.Cells(6).Text & "<br />"
' add the header text plus a new textbox
e.Row.Cells(6).Controls.Add(litHeader)
e.Row.Cells(6).Controls.Add(txtSearch5)
End If
If i = 7 Then
litHeader = New Literal
txtSearch6 = New TextBox
With txtSearch6
'.Text = "fdfdsfd"
.Width = 75
.ID = "txtname7"
End With
' get the current header text
litHeader.Text = e.Row.Cells(7).Text & "<br />"
' add the header text plus a new textbox
e.Row.Cells(7).Controls.Add(litHeader)
e.Row.Cells(7).Controls.Add(txtSearch6)
End If
Next
End If
'End If
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim txt1 As System.Web.UI.WebControls.TextBox = CType(BulkEditGridView1_1.HeaderRow.FindControl("txtname1"), System.Web.UI.WebControls.TextBox)
Dim z As String = txt1.Text
Dim txt2 As System.Web.UI.WebControls.TextBox = CType(BulkEditGridView1_1.HeaderRow.FindControl("txtname2"), System.Web.UI.WebControls.TextBox)
Dim v As String = txt2.Text
Dim txt3 As System.Web.UI.WebControls.TextBox = CType(BulkEditGridView1_1.HeaderRow.FindControl("txtname3"), System.Web.UI.WebControls.TextBox)
Dim vw As String = txt3.Text
s = "SELECT Id,Label,Textbox FROM textboxtable where Id like '" & txt1.Text.Trim() & "%' and label like '" & txt2.Text.Trim() & "%' and Textbox like '" & txt3.Text.Trim() & "%'"
'and TaxName like '" & wt2.Text & "%' and MS01User like '" & wt3.Text & "%' and LUDatetime like '" & wt5.text & "%' and SystemGenerated like '" & wt6.Text & "%' and MS04Status like '" & wt7.Text & "%'"
con.Open()
da = New SqlDataAdapter(s, con)
scb = New SqlCommandBuilder(da)
ds = New DataSet
da.Fill(ds)
BulkEditGridView1_1.DataSource = ds.Tables(0).DefaultView
BulkEditGridView1_1.DataBind()
con.Close()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
con.Open()
s = "SELECT Id,Label,Textbox FROM textboxtable"
da = New SqlDataAdapter(s, con)
scb = New SqlCommandBuilder(da)
ds = New DataSet
da.Fill(ds)
BulkEditGridView1_1.DataSource = ds.Tables(0).DefaultView
BulkEditGridView1_1.DataBind()
End Sub
End Class