DropDown box in ASP.NET RRS feed

  • Question

  • I am populating a drop down box with a database (see code below), but I don't know how to redirect to a website depending on the choice the user makes. Thanks in advance.

    public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    public void Populate1()
    SqlCommand cmd = new SqlCommand("SELECT * FROM [tblOne]", new SqlConnection(ConfigurationManager.AppSettings["ConnString"]));

    SqlDataReader ddlValues;
    ddlValues = cmd.ExecuteReader();

    DropDownList1.DataSource = ddlValues;
    DropDownList1.DataValueField = "theName";
    DropDownList1.DataTextField = "theName";

    • Moved by nobugz Monday, September 28, 2009 8:40 PM forums.asp.net (From:Visual C# General)
    Monday, September 28, 2009 5:54 PM

All replies

  • Are you redirecting on a button press or just when they change the value of the dropdown? On button press, just get the info from the dropdown and do a Response.Redirect(<url>). If from a change in the value of the dropdown, you need a handler for the SelectedIndexChanged event for the dropdown, and do the same thing.

    Ron Whittle - If the post is helpful or answers your question, please mark it as such.
    Monday, September 28, 2009 6:54 PM