4
Contributors
8
Replies
12
Views
6 Years
Discussion Span
Last Post by aspproject
0

The simplest way to do this is to use the AutoPostBack and OnSelectedIndexChanged properties. When AutoPostBack is set to true, the OnSelectedIndexChanged property will tell application which function to fire. From there you can check out what value was selected, and if it's an acceptable value, redirect as needed.

i.e.:

<asp:DropDownList ID="myDropDown" runat="server" AutoPostBack="true" OnSelectedIndexChanged="MyChangedValueFunction" >
</asp:DropDownList>

then in your code add some thing like

protected void MyChangedValueFunction(object sender, EventArgs e)
{
    //Stuff to redirect here
}

Hope that helps.

0

In dropdownlist is table from database of products, when the product selects to open a product.aspx that has pictures of the product.That is i need.

0

gogs85,

Seeing as I don't know the layout of your database, I am going to make some guesses, but I will let you know how I would do this.

The dropdownlist has "Text" and "Value" properties. When setting the "Text" property, use a descriptive name, "Yellow Lampshade", when setting the "Value" property, use a unique identifier from the database, hopefully the Product_Id or what ever the column is that is the primary key in the Product table.

On the post back event, you can use the "Value" property to construct a redirect url containing that unique id.

i.e.:

Response.Redirect("product.aspx?id=" + myProductDropDownList.SelectedValue);

On the page load of the product.aspx page, you can use Request.QueryString["id"] to get the value, and recover whatever information you need from the database.

Let me know if that works.

0

I have tried your code and it is working fine. It takes me to the page for the results. Thanks a lot.

Regards,

Bilal A. Khan

gogs85,

Seeing as I don't know the layout of your database, I am going to make some guesses, but I will let you know how I would do this.

The dropdownlist has "Text" and "Value" properties. When setting the "Text" property, use a descriptive name, "Yellow Lampshade", when setting the "Value" property, use a unique identifier from the database, hopefully the Product_Id or what ever the column is that is the primary key in the Product table.

On the post back event, you can use the "Value" property to construct a redirect url containing that unique id.

i.e.:

Response.Redirect("product.aspx?id=" + myProductDropDownList.SelectedValue);

On the page load of the product.aspx page, you can use Request.QueryString["id"] to get the value, and recover whatever information you need from the database.

Let me know if that works.

0

set autopostback=true in dropdown change event and call function on onselected change event and redirect it to new page

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.