dropdownlist联动问题 50
privatevoidbinddata(){stringsql="selectDISTINCTsu_id,su_namefromvnet_Opreatorwheresta...
private void binddata()
{
string sql = "select DISTINCT su_id,su_name from vnet_Opreator where state='1' ";
ConSql data = new ConSql();
DataTable Table = data.ExecuteSqlRead(sql);
for (int i = 0; i < Table.Rows.Count; i++)
{
DropDownList1.Items.Add( Table.Rows[i]["su_id"].ToString()+Table.Rows[i]["su_name"].ToString());
DropDownList1.SelectedValue = Table.Rows[i]["su_id"].ToString() + Table.Rows[i]["su_name"].ToString();
}
Table.Dispose();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string sql = "select DISTINCT em_name from vnet_Opreator where state='1' and su_id like '%"+ DropDownList1.SelectedValue +"%' ";
ConSql data = new ConSql();
DataTable Table = data.ExecuteSqlRead(sql);
for (int i = 0; i < Table.Rows.Count; i++)
{
DropDownList2.Items.Add(Table.Rows[i]["em_name"].ToString());
}
Table.Dispose();
}
我这个代码怎么只会在第一次点的时候起作用,第二次就无效了。第二次只会刷新页面,第二个dropdownlist的值不会变。谁知道是怎么回事呀? 展开
{
string sql = "select DISTINCT su_id,su_name from vnet_Opreator where state='1' ";
ConSql data = new ConSql();
DataTable Table = data.ExecuteSqlRead(sql);
for (int i = 0; i < Table.Rows.Count; i++)
{
DropDownList1.Items.Add( Table.Rows[i]["su_id"].ToString()+Table.Rows[i]["su_name"].ToString());
DropDownList1.SelectedValue = Table.Rows[i]["su_id"].ToString() + Table.Rows[i]["su_name"].ToString();
}
Table.Dispose();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string sql = "select DISTINCT em_name from vnet_Opreator where state='1' and su_id like '%"+ DropDownList1.SelectedValue +"%' ";
ConSql data = new ConSql();
DataTable Table = data.ExecuteSqlRead(sql);
for (int i = 0; i < Table.Rows.Count; i++)
{
DropDownList2.Items.Add(Table.Rows[i]["em_name"].ToString());
}
Table.Dispose();
}
我这个代码怎么只会在第一次点的时候起作用,第二次就无效了。第二次只会刷新页面,第二个dropdownlist的值不会变。谁知道是怎么回事呀? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询