//联动 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { DropDownList2.Items.Clear(); RegionDC dc = new RegionDC(); string sub_name = DropDownList1.SelectedValue; DataSet ds = null; if (sub_name.Equals("ALL")) { ds = dc.getEnableRegion(); } else { ds = dc.getRegion_nameBySub_name(DropDownList1.SelectedValue); } if (ds != null) { DropDownList2.DataSource = ds.Tables[0].DefaultView; DropDownList2.DataValueField = "region_name"; DropDownList2.DataBind(); DropDownList2.Items.Insert(0, "ALL"); } else { PageUtil.showToast(this, "数据异常!"); } }
protected void Page_Load(object sender, EventArgs e) { Session["Local"] = "料架设定"; if (!IsPostBack) { SubinventoryDC subdc = new SubinventoryDC(); List <string> list = subdc.getAllSubinventory(); DropDownList1.DataSource = list; DropDownList1.DataBind(); DropDownList1.Items.Insert(0, "ALL"); RegionDC dc = new RegionDC(); DataSet ds = dc.getEnableRegion(); if (ds != null) { DropDownList2.DataSource = ds.Tables[0].DefaultView; DropDownList2.DataValueField = "region_name"; DropDownList2.DataBind(); Region_key.DataSource = ds.Tables[0].DefaultView; Region_key.DataValueField = "region_name"; Region_key.DataBind(); Region_key2.DataSource = ds.Tables[0].DefaultView; Region_key2.DataValueField = "region_name"; Region_key2.DataBind(); } DropDownList2.Items.Insert(0, "ALL"); Region_key.Items.Insert(0, "--------select--------"); } }