CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2007
    Posts
    1

    DropDownList Box

    I have a dropdownlistbox that is populated from a table in a database. When the user clicks on one of the item in the list, I need the page to redirect page(x). How is that done?

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto
    Posts
    805

    Re: DropDownList Box

    make a method called somethign like
    Code:
    myDropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        Response.Redirect("somePage.aspx"); 
    
    }
    then in your DropDownlist add the following property
    Code:
    <asp:DropDownList id="blah" runat="server" OnSelectedIndexChanged="myDropDownList_SelectedIndexChanged">
    </asp:DropDownList>
    and if you need the value that was selected you can use
    Code:
    myDropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList ddlTemp = (DropDownList)sender; 
        int selectedValue = int.parse(ddlTemp.SelectedValue.ToString()); 
        Response.Redirect("somePage.aspx?id="+selectedValue.ToString()); 
    }
    hth,
    mcm
    rate my posts!
    mcm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured