Hi There:
Well, you want to perform a search. first of all you have to construct your query string well and according to data types.
Dim searchCriteriaItemName As String
Dim searchCriteriaItemType As String
Dim searchCmd As String
Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click""
searchCriteriaItemName = ""
searchCriteriaItemType = ""
If txtItemName.Text = "" Then
searchCriteriaItemName = "Products.ItemName '%'"
Else
searchCriteriaItemName = "Products.ItemName LIKE '%" & txtItemName.Text & "%'"
End If
If txtItemType.Text = "" Then
searchCriteriaItemType =
"Products.ItemType Like '%'"
Else
searchCriteriaItemType =
"Products.ItemType LIKE '%" & txtItemType.Text & "%'"
End If
searchCmd = "SELECT [IDno], [ItemName], [IType], [Price], [Quantity], [dateposted],
, [phonenumber] FROM [Products]"
searchCmd = searchCmd + " WHERE " + searchCriteriaItemName + " AND " + searchCriteriaItempType
Me.SqlDataSource2.SelectCommand = searchCmd
Me.SqlDataSource2.DataBind()
End Sub
So, This is the logic, you can modify the code according to your requirements.