提交数据后dropdownlist显示的是刚才选中的值,我想让它显示绑定时的初始值,("全部", "00"),如果去了 if (!IsPostBack)可实现,但取不到DropDownList1的值了。有没有办法?
这是绑定代码。
string sql = "select * from BHQ.ALLCODE where DMLB='BHLB'";
DropDownList1.DataSource = my.getdataview(sql, "w");
DropDownList1.DataTextField = "DMMC1";
DropDownList1.DataValueField = "DMZ";
DropDownList1.DataBind(); ListItem myListItem = new ListItem("全部", "00");
this.DropDownList1.Items.Insert(00, myListItem);
这是绑定代码。
string sql = "select * from BHQ.ALLCODE where DMLB='BHLB'";
DropDownList1.DataSource = my.getdataview(sql, "w");
DropDownList1.DataTextField = "DMMC1";
DropDownList1.DataValueField = "DMZ";
DropDownList1.DataBind(); ListItem myListItem = new ListItem("全部", "00");
this.DropDownList1.Items.Insert(00, myListItem);
再次进入此页面可以把LIST里面的值绑定到dropdownlist上
DropDownList1.Items.Insert(0, new ListItem("全部", "00"));这样
是不是需要再在事件中绑定一下?在哪个事件中啊?怎么重新bind呢?上面的代码已经在 if (!IsPostBack)中绑定了。多谢参与!
是不是需要再在事件中绑定一下?在哪个事件中啊?怎么重新bind呢?上面的代码已经在 if (!IsPostBack)中绑定了。多谢参与!你把绑定写成1个方法,加载的时候掉这个方法,提交后再调一次就好了