在ASP.NET中如何同时绑定两个DROPDOWNLIST控件作为查询条件,比如一个是选择国家,一个选择市,跳转到不同
2个回答
展开全部
就是级联吧:
public void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
EmployeeBll empbll = new EmployeeBll();
// DropDownList2.Items.Remove(DropDownList2.Items.FindByText("--请选择--"));
for (int i = 0; i < this.DropDownList1.Items.Count; i++)
{
if (this.DropDownList1.Items[i].Selected)
{
int dpid = Int32.Parse(this.DropDownList1.SelectedValue);
DataSet myds = empbll.GetEmpByDpid(dpid);
this.DropDownList2.DataSource = myds;
this.DropDownList2.DataValueField = "empid";
this.DropDownList2.DataTextField = "empname";
this.DropDownList2.DataBind();
}
}
}
public void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
EmployeeBll empbll = new EmployeeBll();
// DropDownList2.Items.Remove(DropDownList2.Items.FindByText("--请选择--"));
for (int i = 0; i < this.DropDownList1.Items.Count; i++)
{
if (this.DropDownList1.Items[i].Selected)
{
int dpid = Int32.Parse(this.DropDownList1.SelectedValue);
DataSet myds = empbll.GetEmpByDpid(dpid);
this.DropDownList2.DataSource = myds;
this.DropDownList2.DataValueField = "empid";
this.DropDownList2.DataTextField = "empname";
this.DropDownList2.DataBind();
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询