下拉框txtga01选择的时候,导致txtga52的SelectedIndex 仍然回到 0
以下代码 下拉框txtga01选择某一值,AutopostBack后,导致txtga52的DataTextField值回到第一行,并且txtga01 选择某一值后,SelectedIndex 仍然回到 0,(DataTextField 为空白) 好奇怪, 不知道那里出了问题.
//求得下拉框的参数
Maticsoft.BLL.Apm bll = new Maticsoft.BLL.Apm();
DataTable idt;
idt = bll.GetAllList().Tables[0];
ViewState["dt"] = idt;
//加工点
DataView dv1 = new DataView(idt);
dv1.RowFilter = ("parentcode='35'");
txtga52.DataSource = dv1;
txtga52.DataTextField = "cinvcname";
txtga52.DataValueField = "no";
txtga52.DataBind();
//产品
DataView dv2 = new DataView(idt);
dv2.RowFilter = ("parentcode='3001'");
txtga01.DataSource = dv2;
txtga01.DataTextField = "cinvcname";
txtga01.DataValueField = "no";
txtga01.DataBind();
//添加产品空白项
this.txtga01.Items.Insert(0, new ListItem("", ""));
this.txtga01.SelectedIndex = 0;
------解决方案--------------------
你 AutoPostBack 后刷新页面了,肯定会初始化 txtga52 啊。
至于你说的 value 。。没看出来。。