Accessing data has evolved in ASP.NET to include new controls such as the SqlDataSource control. The SqlDataSource class provides a FilterExpression property that can be used to filter the results of calling the SqlDataSource class' Select method.
The code example that follows is all the code needed to drive a web page where a user can enter part or all of a last name to filter the rows of a GridView:

Code Example
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub setFilterButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles setFilterButton.Click
Me.SetFilter()
End Sub
Protected Sub SetFilter()
Dim filterExpression As String = "LastName LIKE '" & Me.filterTextBox.Text & "*'"
Response.Write("Filter expression in effect is: " & filterExpression)
Me.AccessDataSource1.FilterExpression = filterExpression
End Sub
Protected Sub clearFilterButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles clearFilterButton.Click
Me.filterTextBox.Text = ""
Me.SetFilter()
End Sub
Protected Sub X()
Dim filterExpression As String = "LastName LIKE 'Gr'"
Me.AccessDataSource1.FilterExpression = filterExpression
Me.AccessDataSource1.
End Sub
End Class
Click the link below to download ASP source code and Visual Basic source code in a Microsoft Visual Studio 2005 ASP.NET 2.0 solution which demonstrates how to use the SqlDataSource FilterExpression property to filter the rows displayed in an ASP.NET 2.0 GridView.
Filter SqlDataSource Select Method Call