private void CreateSingleHospitalDoctorGroup(int i) { // 1: 国内 2: 国外 string strLocationType = this.ddlLocalType.SelectedItem.Value; //Label lbl = new Label(); //lbl.Text = "目的地"; //lbl.CssClass = "fg-gray"; //panDoctorGroup.Controls.Add(lbl); //DropDownList ddl = new DropDownList(); //ddl.ID = "ddlLocation" + i.ToString(); //ddl.AutoPostBack = true; //ddl.SelectedIndexChanged += new EventHandler(ddlLocation_SelectedIndexChanged);//给ddl添加事件 //ddl.CssClass = "input-control select"; //ddl.DataSource = Consult_ApplicationDAL.GetLoctionList(this.ddlLocalType.SelectedValue); //ddl.DataTextField = "name"; //ddl.DataValueField = "guid"; //ddl.DataBind(); //panDoctorGroup.Controls.Add(ddl); Label lblHospital = new Label(); lblHospital.Text = "医院"; lblHospital.CssClass = "fg-gray"; panDoctorGroup.Controls.Add(lblHospital); DropDownList ddlHospital = new DropDownList(); ddlHospital.ID = "ddlHospital" + i.ToString(); ddlHospital.AutoPostBack = true; ddlHospital.SelectedIndexChanged += new EventHandler(ddlHospital_SelectedIndexChanged);//给ddl添加事件 ddlHospital.CssClass = "input-control select"; ddlHospital.DataSource = Consult_ApplicationDAL.GetHospitalListByLocationType(strLocationType); ddlHospital.DataTextField = "name"; ddlHospital.DataValueField = "guid"; ddlHospital.DataBind(); panDoctorGroup.Controls.Add(ddlHospital); Label lblDoctor = new Label(); lblDoctor.Text = "医生"; lblDoctor.CssClass = "fg-gray"; panDoctorGroup.Controls.Add(lblDoctor); DropDownList ddlDoctor = new DropDownList(); ddlDoctor.ID = "ddlDoctor" + i.ToString(); ddlDoctor.CssClass = "input-control select"; ddlDoctor.DataSource = Consult_ApplicationDAL.GetDoctorList(ddlHospital.SelectedValue, strLocationType); ddlDoctor.DataTextField = "name"; ddlDoctor.DataValueField = "guid"; ddlDoctor.DataBind(); panDoctorGroup.Controls.Add(ddlDoctor); }
protected void ddlHospital_SelectedIndexChanged(object sender, EventArgs e) { // Update the Doctor by Hospital //this.ddlDoctor.DataSource = ApplicationDAL.GetDoctorList(this.ddlHospital.SelectedValue, ""); //this.ddlDoctor.DataBind(); DropDownList ddl = sender as DropDownList; if (ddl != null) { string id = ddl.ID.Replace("ddlHospital", ""); DropDownList ddlDoctor = this.panDoctorGroup.FindControl("ddlDoctor" + id) as DropDownList; ddlDoctor.DataSource = Consult_ApplicationDAL.GetDoctorList(ddl.SelectedValue, ""); ddlDoctor.DataBind(); } }