Click here to Skip to main content
15,902,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to give hyperlink of each item in dropdownlist in asp.net.Kindly give me the proper code for that.
Posted

Create the dropdown with autopostback
XML
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="Sel_Changed" AutoPostBack="True">
<asp:listitem >Google</asp:listitem>
<asp:listitem >Yahoo</asp:listitem>  
  </asp:DropDownList>

In the code

C#
protected void Sel_changed(object sender, EventArgs e)
{
switch (DropDownList1.SelectedIndex)
{
case 1:
    Server.Transfer("www.google.com");
    break;
case 2:
    Server.Transfer("www.Yahoo.com");
    break;
}


}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900