Rocky Rocky

Rocky Rocky

  • NA
  • 317
  • 151.1k

How to show the selected value from drop down from one page

Feb 28 2014 5:16 AM
Hi Friends,


i m creating one web application my requirements are

1)country: Default label

2)States : COMBO BOX
(when i choose the value from the box the page ll be redirect)



for example:


country : INDIA


states : list show "TN,PONDI"


when i choose pondi ll redirect into "pondi.aspx"

but my drop down box was not show the selected value(i.e combo box again showed --- select--- but i need selected "PONDI" in combo after page redirect)



my codes for combobox:


Select Country:  
<asp:TextBox ID="TextBox1" runat="server" Text="India" Height="17px" Width="82px"></asp:TextBox><br /> <br />
Select State: &nbsp;<asp:DropDownList ID="ddlstate" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlstate_SelectedIndexChanged">
<asp:ListItem Text="Select" Value="0">--select--</asp:ListItem>
<asp:ListItem Text="Pondicherry" Value="1">Pondicherry</asp:ListItem>
<asp:ListItem Text="TamilNadu" Value="2">Tamil Nadu</asp:ListItem>
</asp:DropDownList>



in c#:


protected void ddlstate_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlstate.SelectedItem.Text == "Pondicherry")
{

Server.Transfer("Pondi.aspx?ddlstateonnextpage" + AB);
}
else if (ddlstate.SelectedItem.Text == "Tamil Nadu")
{
Server.Transfer("TN.aspx?ddlstateonnextpage" + AB);
}



}

}





how to make code?

thanks & Regards

rocky

Answers (1)