日期:2014-05-17 浏览次数:20495 次
private void getName()
{
this.DropDownList1.DataSource =DropDownList1();
this.DropDownList1.DataValueField = "id";
this.DropDownList1.DataTextField = "name";
this.DropDownList1.DataBind();
this.DropDownList1.Items.Insert(0, new ListItem("--请选择--", "0"));
this.DropDownList2.Items.Insert(0, new ListItem("--请选择--", "0"));
this.DropDownList3.Items.Insert(0, new ListItem("--请选择--", "0"));
}
//点击第一级获得第二级数据
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string id = this.DropDownList1.SelectedValue;
this.DropDownList2.DataSource =GetDropDownList2(id);
this.DropDownList2.DataValueField = "id";
this.DropDownList2.DataTextField = "name";
this.DropDownList2.DataBind();
this.DropDownList3.Items.Insert(0, new ListItem("--请选择--", "0"));
}
//点击第二级获得第三级数据
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
string id = this.DropDownList2.SelectedValue;
this.DropDownList3.DataSource = GetDropDownList3(id);
this.DropDownList3.DataTextField = "name";
this.DropDownList3.DataValueField = "id";
this.DropDownList3.DataBind();
this.DropDownList3.Items.Insert(0, new ListItem("--请选择--", "0"));
}