无论如何都要从c#中获取RadCombobox的最后一个选定值。请指教
我做了类似的事
protected void cboTest_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
Session["CurrentItem"] = e.value;
}
public int GetLastSelectedItem
{
set { Session["CurrentItem"] = value;}
}
then i need to access the session
int productId = 0;
productId = //need to assigned previous selected radcombo value
答案 0 :(得分:0)
您可以尝试以下代码
string old_value = "";
string new_value = "";
protected void cboTest_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
old_value = e.OldValue;
new_value = e.Value;
//do whatever you want with these values
}
答案 1 :(得分:0)
Ummar是对的,现在如果你想通过应用你的代码来做到这一点,试试这个:
我建议使用ViewState,会话变量总是难以处理,如果只是以那种形式需要它也没有意义。
这样的事情:
string LastSelectedValue
{
get { return ViewState["LastSelectedValue"] as string; }
set { ViewState["LastSelectedValue"] = value; }
}
protected void cboTest_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
if(string.IsNullOrEmpty(this.LastSelectedValue))
{
//This is the first time the user changes the index
}
else
{
//The last selected Value is stored in this.LastSelectedValue
}
// last line of your code must be this one
this.LastSelectedValue = this.cboTest.SelectedValue;
}