CREATE TABLE [dbo].[StateMaster](
[StateIdfr] [bigint] IDENTITY(1,1) NOT NULL,
[StateName] [varchar](50) NULL
)
Write Code for Textbox and Button in Front End with a Grid
Sub BindGrid()
Dim dt As New DataTable
dt = Obj.GetStateDetails(txtSearch.Text.Trim)
If dt.Rows.Count > 0 Then
dgdState.DataSource = dt
dgdState.DataBind()
Else
lblMsg.Text = "No Records"
dgdState.DataSource = Nothing
dgdState.DataBind()
End If
End Sub
Call the Above Bindgrid function when Click Search Button
---
Function Class
Public Function GetStateDetails(ByVal StateName As String) As DataTable
Dim dt As New DataTable
Dim da As New SqlDataAdapter("Select StateIdfr,StateName, from StateMaster where StateName='%" & StateName & "", Con)
da.Fill(dt)
Return dt
End Function