DropDownList关联不刷新问题!
如何让DropDownList关联,但不刷新,请各位高手给段代码让我参考一下!!!
我原来的代码,刷新才能实现关联,能否帮我改一下,谢谢。
//DropDownList1数据绑定
sqlConnection1.Open();
ds1=sqlCommand1.ExecuteReader();
DropDownList1.DataSource=ds1;
DropDownList1.DataTextField="Subentry";
DropDownList1.DataValueField="Aclassid";
if (!IsPostBack)
{
DropDownList1.DataBind();
}
ds1.Close();
sqlConnection1.Close();
//DropDownList2根据DropDownList1.DataValueField值进行绑定
this.sqlCommand1.CommandText = "SELECT subentry,Anclassid FROM Bnclass WHERE (Aclassid = '"+DropDownList1.SelectedItem.Value+"')";
this.sqlCommand1.Connection = this.sqlConnection1;
sqlConnection1.Open();
ds1=sqlCommand1.ExecuteReader();
DropDownList2.DataSource=ds1;
DropDownList2.DataTextField="subentry";
DropDownList2.DataValueField="Anclassid";
if (!IsPostBack)
{
DropDownList2.DataBind();
}
ds1.Close();
sqlConnection1.Close();