0

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

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by khadakbist
0

Firstly, in search page, instead of placing if statements, why dont you simply:

Response.Redirect("Search Page.aspx?Catagory="& CatagoryList.SelectedItem.Value &"&city=" & ItemList.SelectedItem.Value & "")

secondly, can you actually see the parameters being passed in the URL in the result page?

0

pass multiple values in query string like categoryid=action,test1,test2
and use this values in query.
Like WHERE Item in 'Action,test1,test2'

0

Sorry i read your post twice i understood the scenario but not the problem can you clarify your problem again. Sorry for asking you to repeat.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.