根据会话下拉选择

根据会话下拉选择

问题描述:

我有一个下降,其中包含学期的价值。它是管理面板的一个组件,所以我想保持以前选择的下拉值。我怎么能在ASP.Net中这样做。我已经用PHP完成了这个,但我是ASP.net的新手,所以请帮助我。



准确:假设我每次重新加载都选择了第二学期页面下拉列表中的默认值semester-2应该到来。

I am having a drop down which contaion semester as its values. Its a component of admin panel so i want to maintain the previously selected drop-down value. How can i do this in ASP.Net. I have done this in PHP but i am new to ASP.net so please help me.

Being precise : suppose i have selected Semester-2 then every time I reload the page the default value semester-2 in the drop-down should come.

在DropDownlist中,selectedindexchanged事件将会话中的选定值存储为;

In DropDownlist selectedindexchanged event store the selected value in session as;
Session["DDSelectedValue"] = YourDropDownlistID.SelectedValue;



现在,您需要从会话中设置值。如果管理面板是用户控件或主页等。



要在绑定下拉列表时设置值,请使用:


Now it depends upon you to set the value from session. If the admin panel is user control or on master page etc.

To set the value whenever you bind the dropdownlist use:

YourDropDownlistID.SelectedValue = Session["DDSelectedValue"].ToString();



进一步澄清你的代码。


for further clarification post your code.