Dear All,
I have a search page on which I have two DropDownLists. One for Catagory and another for Item. When I select both of them it takes me to the result page and displays the result in GridView. It works for a single value but for more than one Catagories and Items, I need to put condition statements.
I am using Response.Direct in the search page and Request.QueryString on the result page.
The search page code is given below:
If CatagoryList.SelectedItem.Value = "Movies" And ItemList.SelectedItem.Value = "Action" Then
'Redirect to the search result page
Response.Redirect("Search Page.aspx?Catagory=Movies&city=Action")
The code at the result page is given below:
Dim Catagory As String
Dim Item As String
Catagory = Request.QueryString("Catagory")
Item = Request.QueryString("Item")
'lblcatagory.Text = specialization
'lblitem.Text = city
If Catagory = "Movies" And Item = "Action" Then
Dim connectionstring As String = WebConfigurationManager.ConnectionStrings("Register").ConnectionString
Dim con As New SqlConnection(connectionstring)
Dim selectsql As String = "SELECT Name, ReleaseDate FROM Table_Name WHERE Item='Action' ORDER BY Name"
Dim cmd As New SqlCommand(selectsql, con)
Dim adapter As New SqlDataAdapter(cmd)
'Fill the dataset
Dim ds As New DataSet()
adapter.Fill(ds, "Table_Register")
'Perform Binding
SearchResultGrid.DataSource = ds
SearchResultGrid.DataBind()
Now note that if I do not enter the Request.QueryString code and give only binding code, it works perfectly fine. Note another thing that I have tested the Request.QueryString code by putting the labels (You can see the code above). The values are passed perfectly.
Can anyone please tell me what is the problem with my code?
Thank you in anticipation.
Best Regards,
Bilal A. Khan