i have to insert some data value and value like this picture on insert.aspx
And how i show like this to update the data update.aspx
So how to make check box on update.aspx check automatic like on insert.aspx
on Insert.aspx.vb
Protected Sub insertdata()
Dim cls As New connections
cls.openconnections()
Dim cmd As New SqlClient.SqlCommand
cmd.Connection = cls.cn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "sp_inserttrainer"
cmd.Parameters.AddWithValue("#id", txtKode.Text)
cmd.Parameters.AddWithValue("#nama", txtnama.Text)
cmd.Parameters.AddWithValue("#status", txtstatus.SelectedValue)
cmd.Parameters.AddWithValue("#alamat", txtalamat.Text)
cmd.Parameters.AddWithValue("#telp", txttel.Text)
cmd.Parameters.AddWithValue("#hp", txthp.Text)
cmd.Parameters.AddWithValue("#email", txtemail.Text)
cmd.ExecuteNonQuery()
cls.closeconnection()
End Sub
Protected Sub savedatamateri()
Dim cbterpilih As Boolean = False
Dim cb As CheckBox = Nothing
Dim n As Integer = 0
Do Until n = gridsecond.Rows.Count
cb = gridsecond.Rows.Item(n).FindControl("chkStatus")
If cb IsNot Nothing AndAlso cb.Checked Then
cbterpilih = True
Dim cls As New connections
cls.openconnections()
Dim cmd As New SqlClient.SqlCommand
cmd.Connection = cls.cn
cmd.CommandText = "Insert Into m_trainer_detil (trainer_id, materi_id)"
cmd.CommandText &= "values(#triner, #materi)"
Dim com As HiddenField = CType(gridsecond.Rows(n).FindControl("HiddenField2"), HiddenField)
cmd.Parameters.AddWithValue("#triner", txtKode.Text)
cmd.Parameters.AddWithValue("#materi", com.Value)
cmd.ExecuteNonQuery()
cls.closeconnection()
End If
n += 1
Loop
End Sub
Protected Sub insert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles insert.Click
If txtalamat.Text = "" Then
labelran.Text = "Tolong isi Alamat"
ElseIf txtemail.Text = "" Then
labelran.Text = "Tolong isi Email"
ElseIf txtnama.Text = "" Then
labelran.Text = "Tolong isi Nama"
ElseIf txttel.Text = "" Then
labelran.Text = "Tolong isi Telepon"
ElseIf txthp.Text = "" Then
labelran.Text = "Tolong isi Handphone"
Else
insertdata()
savedatamateri()
listhendle()
End If
End Sub
and for update.aspx.vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
listhendle()
listmateri()
End If
End Sub
Protected Sub listhendle()
Dim ds As New DataSet
Dim cls As New connections
ds = cls.returndataset("select * from [m_trainer] ")
If ds.Tables(0).Rows.Count = 0 Then
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
End If
griddata.DataSource = ds
griddata.DataBind()
End Sub
Protected Sub listmateri()
Dim ds As New DataSet
Dim cls As New connections
ds = cls.returndataset("select * from [m_materi] ")
If ds.Tables(0).Rows.Count = 0 Then
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
End If
gridsecond.DataSource = ds
gridsecond.DataBind()
End Sub
Protected Sub griddata_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles griddata.SelectedIndexChanging
Dim kode As HiddenField = CType(griddata.Rows(e.NewSelectedIndex).FindControl("HiddenField1"), HiddenField)
txtKode.Text = kode.Value
txtnama.Text = Replace(griddata.Rows(e.NewSelectedIndex).Cells(1).Text, " ", "")
txtalamat.Text = Replace(griddata.Rows(e.NewSelectedIndex).Cells(2).Text, " ", "")
txttel.Text = Replace(griddata.Rows(e.NewSelectedIndex).Cells(3).Text, " ", "")
txthp.Text = Replace(griddata.Rows(e.NewSelectedIndex).Cells(4).Text, " ", "")
txtstatus.SelectedValue = Replace(griddata.Rows(e.NewSelectedIndex).Cells(5).Text, " ", "")
txtemail.Text = Replace(griddata.Rows(e.NewSelectedIndex).Cells(6).Text, " ", "")
End Sub
But i don't know how connect materi with database
Thank You
It looks like you are storing the materi_id in the table m_trainer. So it looks like you would need to set up an OnRowDataBound event on your "gridSecond" GridView. Within the OnRowDatabound event get a dataset for the selected trainer_id and if the materi_id exists within that dataset set its checked value as true.
Related
Currently can not get any SQL data to populate the web form. When I run the report in Visual Studio preview mode, the data populates, however when running through my web app it displays nothing.
Imports System.Data.SqlClient
Public Class topvendors
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
getEntity()
' startdate.Text = DateTime.Today.ToShortDateString
End If
End Sub
Protected Sub getEntity()
Dim strConnString As String = Session("strconnection") 'ConfigurationManager.ConnectionStrings("TrialConnectionString").ConnectionString
Dim con As New SqlConnection(strConnString)
Dim cmd As New SqlCommand()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "pGetProjectsByUser"
cmd.Parameters.Add("#employeeid", SqlDbType.Int).Value = Session("userid")
cmd.Parameters.Add("#reportid", SqlDbType.Int).Value = Request.QueryString("id")
cmd.Connection = con
Try
con.Open()
Dim dt As New DataTable()
Dim ds As New DataSet()
'Dim db As New SqlDataAdapter(cmd)
Dim da = New SqlDataAdapter(cmd)
da.Fill(ds)
'db.Fill(ds)
division.DataSource = ds.Tables(0)
division.DataTextField = "entityname"
division.DataValueField = "entitycode"
division.DataBind()
' If ds.Tables(0).Rows.Count > 1 Then
'divisions.Visible = False
' communities.DataSource = ds.Tables(1)
'communities.DataTextField = "Projectname"
' communities.DataValueField = "projID"
' communities.DataBind()
' Else
' divisions.Text = ds.Tables(0).Rows(0)("entityname").ToString
'division.Visible = False
' communities.DataSource = ds.Tables(1)
'communities.DataTextField = "Projectname"
'communities.DataValueField = "projID"
'communities.DataBind()
'End If
Catch ex As Exception
Throw ex
Finally
con.Close()
con.Dispose()
End Try
End Sub
Protected Sub submit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles submit.Click
' Dim communities As String = Server.UrlEncode(Request.Form("communities"))
' Response.Write(communities)
' Dim removedays As Integer = Request.Form("removedays")
'getEntity()
' MsgBox(sort.SelectedValue)
Dim builder As New System.Data.SqlClient.SqlConnectionStringBuilder
builder = New SqlConnectionStringBuilder(Session("strconnection"))
Dim databasename As String = builder.InitialCatalog
Dim dataname As String
If databasename = "G3Live" Then
dataname = "2fLiveReports"
Else
dataname = "2fTestReports"
End If
Response.Redirect("http://g3reports.danryanbuilders.com/ReportServer/Pages/ReportViewer.aspx?%" + dataname + "%2fPurchasing%2flance_tutorial&rs:Format=Excel&rs%3aCommand=Render&entityid=" & division.SelectedValue & "&begindate=" + begindate.Text + "&enddate=" + enddate.Text + "&sort=" + DropdownList1.SelectedValue)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim builder As New System.Data.SqlClient.SqlConnectionStringBuilder
builder = New SqlConnectionStringBuilder(Session("strconnection"))
Dim databasename As String = builder.InitialCatalog
Dim dataname As String
If databasename = "G3Live" Then
dataname = "2fLiveReports"
Else
dataname = "2fTestReports"
End If
Response.Redirect("http://g3reports.danryanbuilders.com/ReportServer/Pages/ReportViewer.aspx?%" + dataname + "%2fPurchasing%2flance_tutorial&rs:Format=PDF&rs%3aCommand=Render&entityid=" & division.SelectedValue & "&begindate=" + begindate.Text + "&enddate=" + enddate.Text + "&sort=" + DropdownList1.SelectedValue)
End Sub
End Class
Note: You are storing connection string in Session, it is not recommendable. You can do but it is better you should use web.config
file to store connection string.
You can be refer this: Avoid storing connection string in session for different sql schema
For Solution I recommended
You must check the session variable prior to getting the value for the connection string.
' Check if session is null
If Not (Session("strconnection ") Is Nothing) Then
{
//
}
When it is Null or Nothing or Empty, try to retrieve the connection string again.
You need to cast session variables into their correct types, before use like
Session("strconnection")
Replace it by
Session("strconnection").toString()
And
Cast Session("userid") and Request.QueryString("id") by the help of
Integer.Parse/ Integer.TryParse
you can read this for concept:
Return Value From Session
I'm trying to get the gridview details to be put into textboxes for better view and edit.
I'm listing the following code to create the gridview:
'Finds all cases that are not closed
Protected Sub listAllCases()
sqlCommand = New SqlClient.SqlCommand("SELECT TC.caseId,TS.subName,TSU.userName,TC.caseType,TC.caseRegBy,TC.caseTopic,TC.caseDesc,TC.caseSolu,TC.caseDtCreated, TC.caseStatus FROM TBL_CASE TC INNER JOIN TBL_SUBSIDIARY_USER TSU ON TC.caseUser = TSU.userID INNER JOIN TBL_SUBSIDIARY TS on TSU.usersubId = TS.subId WHERE TC.caseStatus = 0 order by caseId")
sqlCommand.Connection = sqlConnection
sqlConnection.Open()
'sqlCommand.Parameters.AddWithValue("#subID", Me.caseSub.SelectedItem.Value)
Dim dr As SqlClient.SqlDataReader
dr = sqlCommand.ExecuteReader
If dr.HasRows Then
allCases.DataSource = dr
allCases.DataBind()
Else
allCases.DataSource = Nothing
allCases.DataBind()
End If
dr.Close()
sqlConnection.Close()
End Sub
Then I use the a function on the gridview onselectindexchanged and Writes this:
Protected Sub OnSelectedIndexChanged(sender As Object, e As EventArgs)
Dim row As GridViewRow = allCases.SelectedRow
txtcase.Text = row.Cells(1).Text()
txtsub.Text = row.Cells(2).Text
txtuser.Text = row.Cells(3).Text
oDato.Text = row.Cells(9).Text
lDato.Text = "Saken er ikke lukket!"
txttype.Text = row.Cells(4).Text.ToString
txtregBy.Text = row.Cells(5).Text.ToString
txttopic.Text = row.Cells(6).Text
txtDesc.Text = row.Cells(7).Text
txtSolu.Text = row.Cells(8).Text
lblinfo.Text = row.Cells(6).Text
End Sub
I only get it to display cells 1 to 9. Means cell 4 to 8 is not listed or being blank, even though i know it should contain data.
Any tips or Clues is very appreciated!
Like This ?
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As
TextBox1.text = DataGridView1.Rows(e.Index).Cells(0).value.toString
TextBox2.text = DataGridView1.Rows(e.Index).Cells(1).value.toString
TextBox3.text = DataGridView1.Rows(e.Index).Cells(2).value.toString
TextBox4.text = DataGridView1.Rows(e.Index).Cells(3).value.toString
TextBox5.text = DataGridView1.Rows(e.Index).Cells(4).value.toString
TextBox6.text = DataGridView1.Rows(e.Index).Cells(5).value.toString
TextBox7.text = DataGridView1.Rows(e.Index).Cells(6).value.toString
TextBox8.text = DataGridView1.Rows(e.Index).Cells(7).value.toString
TextBox9.text = DataGridView1.Rows(e.Index).Cells(8).value.toString
TextBox10.text = DataGridView1.Rows(e.Index).Cells(9).value.toString
End Sub
This will display all the information in the row by clicking the record...
e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
sorry for that ...
by clicking the data the (e.Index) will locate in which DataGridView.Rows(), then the cells.(n) and etc... will get your data
ok. i got it right, finally. the code i used to get it work is as follows:
Protected Sub allCases_OnSelectedIndexChanged(sender As Object, e As EventArgs)
Dim row As GridViewRow = allCases.SelectedRow
txtcase.Text = row.Cells(1).Text()
txtsub.Text = row.Cells(2).Text.ToString
txtuser.Text = row.Cells(3).Text
oDato.Text = row.Cells(9).Text
txtDesc.Text = TryCast(row.FindControl("lblcaseDesc"), Label).Text
txtSolu.Text = TryCast(row.FindControl("lblcaseSolu"), Label).Text
end sub
this means I need to fetch the boundfields and templatefields differently.
Anyhow thanks for the reponse.
How can I automatically input a number to a textbox after clicking a button upon selecting an item from a combobox. All I know to do is to get the data from the combobox to textbox. But what I would like to do is to add data to a textbox once the item is selected.
This is My Code:
Imports System.Data.OleDb
Imports System.Data
Public Class voting1
Dim con As New OleDbConnection
Dim Com As New OleDbCommand
Dim ComInsert As New OleDbCommand
Dim ComUpdate As New OleDbCommand
Dim ComDelete As New OleDbCommand
Dim aAdapter As New OleDbDataAdapter
Dim Dset As New DataSet
Private Sub voting1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ConProvider As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=J:\EvS\EVS.accdb"
Try
Try
con.ConnectionString = ConProvider
If Not con.State = ConnectionState.Open Then
con.Open()
End If
Catch ex As Exception
MsgBox("No Connection Established")
End Try
Me.fill()
user.Visible = False
user.Text = Form1.usertxt.Text
Catch ex As Exception
End Try
End Sub
Private Sub fill()
With aAdapter
.SelectCommand = New OleDb.OleDbCommand()
.SelectCommand.CommandText = "select * from candidate"
.SelectCommand.Connection = con
End With
Dim dataRead As OleDb.OleDbDataReader
dataRead = aAdapter.SelectCommand.ExecuteReader()
While (dataRead.Read())
presbox.Items.Add(dataRead("President"))
vpbox.Items.Add(dataRead("VicePresident"))
secbox.Items.Add(dataRead("Secretary"))
treasbox.Items.Add(dataRead("Treasurer"))
End While
aAdapter.Dispose()
End Sub
Public Sub Initialize()
Try
If Not con.State = ConnectionState.Open Then
con.Open()
End If
Catch ex As System.Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "ERROR CONNECTION")
End Try
End Sub
Private Sub bo()
Dim con1 As New OleDbConnection
Dim cmd As New OleDbCommand
con1.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=J:\EvS\EVS.accdb"
cmd.Connection = con1
con1.Open()
Dim num As Integer
cmd.CommandText = "SELECT pres1 FROM vote1"
If IsDBNull(cmd.ExecuteScalar) Then
num = 1
samp.Text = num
Else
num = 1
samp.Text = num
End If
cmd.Dispose()
con1.Close()
con1.Dispose()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Call Initialize()
If presbox.Text = "" Or vpbox.Text = "" Or secbox.Text = "" Or treasbox.Text = "" Then
MsgBox("All Fields are required, Check the fields", MsgBoxStyle.Information, "Required Fiels")
Exit Sub
End If
With aAdapter
.SelectCommand = New OleDb.OleDbCommand()
.SelectCommand.CommandText = "select * from [vote] where username = '" & user.Text & "'"
.SelectCommand.Connection = con
End With
Dim dataRead As OleDb.OleDbDataReader
dataRead = aAdapter.SelectCommand.ExecuteReader()
If Not dataRead.HasRows Then
ComInsert.CommandText = "INSERT INTO vote([username],[president],[vicePresident],[secretary],[treasurer])" & _
"VALUES('" & user.Text & "','" & presbox.Text & "','" & vpbox.Text & "','" & secbox.Text & "','" & treasbox.Text & "')"
ComInsert.Connection = con
ComInsert.ExecuteNonQuery()
MsgBox("Voting Successful!", MsgBoxStyle.Information, "NEW RECORD")
Form1.Show()
Me.Close()
aAdapter.Dispose()
ComInsert.Dispose()
Else
MsgBox("WARNING: User Voted Already!!", MsgBoxStyle.Exclamation, "ERROR SAVING DATA")
Me.Close()
Form1.Show()
End If
Catch ex As Exception
End Try
End Sub
End Class
There are a couple of ways to do this if I am understanding what you are wanting.
1.) We can just check if there is anything in the combobox.text property.
If String.IsNullOrEmpty(cbobox.text) Then
Perform the logic of adding data to textbox here.
cbobox.text = null
End If
That is the most simple way, but you will have to set the combobox back to null after the data is added to make it work again.
2.) We can make use of the Combobox.SelectedIndexChanged method.
Here is the documentation website: http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selectedindexchanged.aspx
Here is an example:
private void ComboBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
perform logic here
}
Hope this helps.
Private Sub p1()
If Not con.State = ConnectionState.Open Then
con.Open()
End If
Com = con.CreateCommand
Com.CommandText = "SELECT COUNT(vote.presnum) as countofpres FROM vote WHERE presnum ='1';"
Dim dt As OleDb.OleDbDataReader = Com.ExecuteReader
dt.Read()
Dim countpres As Integer = dt("countofpres")
Me.pres1.Text = countpres
dt.Close()
End Sub
here it is Jlott
I've used ASP's CheckBoxList control. Now what I want is to get the all selected values in VB code.
HTML
<asp:CheckBoxList ID="chkbxlst_Users" runat="server" RepeatColumns="2" RepeatDirection="Vertical" RepeatLayout="Table"></asp:CheckBoxList>
VB
Protected Sub btnSaveSetProject_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveSetProject.Click
Dim ds_selectedProjects As New DataSet
Dim eStr As String = String.Empty
Try
Catch ex As Exception
Me.ShowErrorMessage(ex.Message, "...btnSaveSetProject")
End Try
End Sub
On this Save button's click I want to get all the selected items' value and text in dataset.
try this..
For Each li As ListItem In chkbxlst_Users.Items
If li.Selected Then
// add item data into your dataset
Else
// do whatever you need
End If
End If
Next
You can try following code:
Protected Sub btnSaveSetProject_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveSetProject.Click
Dim ds_selectedProjects As New DataSet
Dim dt = New DataTable()
Dim dcName = New DataColumn("Name", GetType(String))
dt.Columns.Add(dcName)
Dim eStr As String = String.Empty
Try
For Each checkBox As CheckBox In chkbxlst_Users.Items
If (checkBox.Checked = True) Then
Dim dr As DataRow = dt.NewRow()
dr("ID") = checkBox.Text
dt.Rows.Add(dr)
End If
Next
ds_selectedProjects.Tables.Add(dt)
Catch ex As Exception
'Me.ShowErrorMessage(ex.Message, "...btnSaveSetProject")
End Try
End Sub
Try this code
Dim ds_selectedProjects As New DataSet
Dim dt_selectedProjects As New DataTable
dt_selectedProjects.Columns.Add("Value")
dt_selectedProjects.Columns.Add("Text")
Dim dr As DataRow
For i = 0 To chkbxlst_Users.Items.Count - 1
If chkbxlst_Users.Items(i).Selected Then
dr = dt_selectedProjects.NewRow()
dr("Value") = Val(chkbxlst_Users.Items(i).Value)
dr("Text") = chkbxlst_Users.Items(i).Text
dt_selectedProjects.Rows.Add(dr)
End If
Next
ds_selectedProjects.Tables.Add(dt_selectedProjects)
Try this
Dim str As [String] = ""
For i As Integer = 0 To CheckBoxList1.Items.Count - 1
If CheckBoxList1.Items(i).Selected Then
If str = "" Then
str = "'" + CheckBoxList1.Items(i).Value + "'"
Else
str += "," + "'" + CheckBoxList1.Items(i).Value + "'"
End If
End If
Next
'display in a textbox or lable with ID txtmsg
txtmsg.Text = str
At Page Load, I populate the GridView with records. Then I created a search functionality to search for records. The GridView is actually updating based on the search text. The problem is when I select a row, the GridView shows all the records and not the list based on search.
Here is the code:
Imports MySql.Data.MySqlClient
Public Class Main_Admin
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim myConnection As MySqlConnection
Dim myDataAdapter As MySqlDataAdapter
Dim myDataSet As DataSet
Dim strSQL As String
'Dim iRecordCount As Integer
myConnection = New MySqlConnection("server=localhost; user id=root; password=admin; database=db; pooling=false;")
strSQL = "SELECT emp_id AS 'Employee ID', emp_sname AS Surname, emp_fname AS 'First Name', emp_mname AS 'Middle Name', tbl_emp_cat.cat_name AS 'Category', nature AS 'Nature of Employment' FROM tbl_employee JOIN tbl_emp_cat ON tbl_employee.emp_cat = tbl_emp_cat.emp_cat;"
myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)
myDataSet = New DataSet()
myDataAdapter.Fill(myDataSet, "mytable")
GridView1.DataSource = myDataSet
GridView1.DataBind()
myConnection.Close()
End Sub
Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound
e.Row.Cells(0).Width = 100
e.Row.Cells(0).Attributes.CssStyle("text-align") = "center"
e.Row.Cells(1).Width = 100
e.Row.Cells(2).Width = 100
e.Row.Cells(3).Width = 100
e.Row.Cells(4).Width = 100
If (e.Row.RowType = DataControlRowType.DataRow) Then
'e.Row.Attributes("onmouseover") = "this.style.cursor='hand';"
e.Row.Attributes("onmouseout") = "this.style.textDecoration='none';"
e.Row.Attributes("onclick") = ClientScript.GetPostBackClientHyperlink(Me.GridView1, "Select$" & Convert.ToString(e.Row.RowIndex))
e.Row.Attributes.Add("onmouseover", "this.style.cursor='hand';this.style.textDecoration='underline';")
'e.Row.Attributes.Add("onmouseout", "this.style.textDecoration='none';")
'e.Row.Attributes.Add("onclick", ClientScript.GetPostBackClientHyperlink(Me.GridView1, Page.ClientScript.GetPostBackEventReference(GridView1, e.Row.RowIndex)))
' "Select$" + e.Row.RowIndex.ToString())
End If
End Sub
Protected Sub GridView1_PageIndexChanging(sender As Object, e As GridViewPageEventArgs)
GridView1.SelectedIndex = -1
End Sub
Private Sub search_Click(sender As Object, e As EventArgs) Handles search.Click
Dim myConnection As MySqlConnection
Dim myDataAdapter As MySqlDataAdapter
Dim myDataSet As DataSet
Dim strSQL As String
'Dim iRecordCount As Integer
myConnection = New MySqlConnection("server=localhost; user id=root; password=admin; database=db; pooling=false;")
strSQL = "SELECT emp_id AS 'Employee ID', emp_sname AS Surname, emp_fname AS 'First Name', emp_mname AS 'Middle Name', tbl_emp_cat.cat_name AS 'Category', nature AS 'Nature of Employment' FROM tbl_employee JOIN tbl_emp_cat ON tbl_employee.emp_cat = tbl_emp_cat.emp_cat WHERE emp_sname LIKE '%" & search_text.Text + "%';"
myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)
myDataSet = New DataSet()
myDataAdapter.Fill(myDataSet, "mytable")
GridView1.DataSource = myDataSet
GridView1.DataBind()
myConnection.Close()
End Sub
End Class
A quick glance at your code shows that you are missing this line in you page load
If Not Page.IsPostBack Then
->put your code here
End if
Your grid view is being refreshed each time on page load wiping off your filtering functionality.Hope this helps.