我在回发期间丢失了下拉列表选择的值。 [英] i lost dropdown list selected values during postback.
本文介绍了我在回发期间丢失了下拉列表选择的值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨我的团队,
i有gridview with下拉列表,文本框和一个按钮。如果我选择一个下拉列表将填充其他下拉列表。我通过使用按钮添加了一个新行。但是在回发期间之前的行数据丢失了:-(
然后我从数据库获取数据不是来自数据库。请给出解决方案。
谢谢前进到所有...........
Hi my team,
i have gridview with dropdown list,and text boxes.and one button.if i select the one dropdown it will populate other dropdown list.and i added a new row by using the button.but am getting lost by previous row data during postback:-(.
then am getting data througn "Enum" not from database.please give a solution.
Thanks in advance to all...........
推荐答案
你可以参考下面的代码
您必须在会话中获得选定的值并在回发到下拉列表后设置该值。
例如
Hi ,
You can refer below code
You have to get selected value in session and set that value after postback to the dropdownlist.
e.g.
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Session["DDLValue"] = dropdownlist1.SelectedValue;
}
On page load, get the session and set it to drop down list if it is not NULL:
if(Session["DDLValue"] != null)
{
dropdownlist1.SelectedValue = Session["DDLValue"].ToString();
}
这篇关于我在回发期间丢失了下拉列表选择的值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文