Last post May 30, 2006 12:48 PM by cmonty
May 29, 2006 03:50 AM|cmonty|LINK
Hello, I pulled this script off another thread. It should allow me to keep a Dropdown selection stored in a session variable. So upon post back, it keeps the selected value.
The problem I have is that I’m not a C# buff and I’ve been trying to get it to work using VB.. Any help would be greatly appreciated!
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
if (!this.IsPostBack && (this.Session["mySelectedValue"] != null))
this.DropDownList1.SelectedIndex = Conversions.ToInteger(this.Session["mySelectedValue"]);
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
this.Session["mySelectedValue"] = this.DropDownList1.SelectedIndex;
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Default2.aspx">HyperLink</asp:HyperLink>
May 29, 2006 10:11 AM|e_screw|LINK
May 29, 2006 01:09 PM|cmonty|LINK
The reason i need to store the drop down selection into a session variable is because i have other controls on the page. So when i do a post back on those items, the drop down defaults to its original setting. My goal is to keep the dropdown selection constant,
even on post back.
May 29, 2006 06:42 PM|e_screw|LINK
May 30, 2006 12:48 PM|cmonty|LINK
Yes, thanks for the help… it’s working now! And I also got it in a session variable so that other pages that have the pull down keeps the selection..