I have a DropDownList with button:
<form id="form1" runat="server">
<asp:DropDownList ID="DropDay" runat="server"/>
<input type="submit" value="Save" runat="server" id="btn"/>
</form>
C# code for the page:
protected void Page_Load(object sender, EventArgs e)
{
btn.ServerClick+=new EventHandler(btn_ServerClick);
}
void btn_ServerClick(object sender, EventArgs e)
{
HttpContext value= HttpContext.Current;
value.Items.Add("Day", DropDay.SelectedValue);
Server.Transfer("ASP_2.aspx");
}
In ASP_2 I have a label, that I need to set the selected Dropdownlist value. And here is the code for ASP_2.aspx:
protected void Page_Load(object sender, EventArgs e)
{
HttpContext value= HttpContext.Current;
lblDay.Text = value.Items["Day"].ToString();
}
The problem is, that the value always is the first item from the dropdown. How do I set the selected value?
EDIT
the way I am filling the dropdown list The code goes in Page_Load:
DropDay.Items.Clear();
for (int i = 1; i <= 10; i++)
{
DropDay.Items.Add(i.ToString());
}