protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataSet ds1 = new BLL.Department_Info().GetAllList(); this.ddl_post.DataSource = ds1; ddl_post.DataTextField = "departmentName"; ddl_post.DataValueField = "departmentName"; this.ddl_post.DataBind(); ////这种方法也可以 this.ddl_post.Items.Insert(0, "==请选择=="); this.ddl_post.Items.FindByText("==请选择==").Selected = true; DataSet ds = new BLL.J_Staff_Info.J_Staff_Info().GetList("state = '在职'"); this.ddl_EName.DataSource = ds; ddl_EName.DataTextField = "EName"; ddl_EName.DataValueField = "EName"; this.ddl_EName.DataBind(); } }
selectedIndexChanged事件
protected void ddl_post_SelectedIndexChanged(object sender, EventArgs e) { DataSet ds = new BLL.J_Staff_Info.J_Staff_Info().GetList("post='" + ddl_post.SelectedValue + "' and state = '在职';"); this.ddl_EName.DataSource = ds; ddl_EName.DataTextField = "EName"; ddl_EName.DataValueField = "EName"; this.ddl_EName.DataBind(); }