PFCMIS.BLL.Common.CommonUse bll = new PFCMIS.BLL.Common.CommonUse();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DataSet ds = bll.GetAllList("vwDept");
this.ddlDeptName.DataSource = ds;
this.ddlDeptName.DataTextField = "DeptName";
this.ddlGrade.DataSource = PFCMIS.BLL.Common.CommonUse.GetGradeList();
DataBind();
}
}
protected void ddlDeptName_SelectedIndexChanged(object sender, EventArgs e)
{
DataSet ds = bll.GetList("MajorName,MajorNo", "vwMajor", " DeptName='" + this.ddlDeptName.SelectedItem.Text.Trim() +
"'");
this.ddlMajorName.Items.Clear();
this.ddlMajorName.Items.Add(new ListItem("-请选择-"));
this.ddlMajorName.DataSource = ds;
this.ddlMajorName.DataTextField = "MajorName";
DataBind();
this.ddlClassName.Items.Clear();
this.ddlClassName.Items.Add(new ListItem("-请选择-"));
}
protected void ddlMajorName_SelectedIndexChanged(object sender, EventArgs e)
{
string strWhere = " DeptName='" + this.ddlDeptName.SelectedItem.Text.Trim() + "' and MajorName='" +
this.ddlMajorName.SelectedItem.Text.Trim() + "'";
DataSet ds = bll.GetList("ClassNo,ClassName", "vwClassInfo", strWhere);
this.ddlClassName.Items.Clear();
this.ddlClassName.Items.Add(new ListItem("-请选择-"));
this.ddlClassName.DataSource = ds;
this.ddlClassName.DataTextField = "ClassName";
DataBind();
}
注意把AppendDataBoundItem设置为true