How to show the selected value from drop down from one page into another page in c#?

Posted by Raghuldrag under C# on 2/28/2014 | Points: 10 | Views : 5407 | Status : [Member] | Replies : 3
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




Responses

Posted by: Bandi on: 2/28/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
http://stackoverflow.com/questions/20652047/passing-dropdown-listitem-value-to-another-page

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Raghuldrag, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 2/28/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Use ViewState for passing value to another Page
http://www.codeproject.com/Articles/37753/Access-ViewState-Across-Pages

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Raghuldrag, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sravan661 on: 2/28/2014 [Member] Bronze | Points: 25

Up
0
Down
Hi
Use Querystring and retreve the value in Pondi.aspx and change dropdown selected value in page load .

Hope helps u
Revert if u have any issues
Mark As Answer if satisfied

sravan

Raghuldrag, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response