日期:2014-05-18 浏览次数:20468 次
protected void Page_Load(object sender, EventArgs e) { DataAccessLibrary dal = DALFactory.CreateDAL(); string sql = @"SELECT AreaID AS id, AreaName AS txt FROM Base_Area WHERE (AreaCode LIKE '__0000') SELECT ParentID,AreaID AS id, AreaName AS txt FROM Base_Area WHERE (AreaCode LIKE '____00') AND (AreaCode NOT LIKE '__0000') "; DataSet ds = dal.ExecuteFillDataSet(sql); this.lst_Area.DataSource = ds; this.lst_Area.DataBind(); } protected void btn_Save_Click(object sender, EventArgs e) { //提交表单后,获取联动下拉列表框的选项值 //获取ID string itemID = this.lst_Area.SelectedValue; this.txt_Value.Text = itemID; //获取text string itemText = this.lst_Area.SelectedText; this.txt_Value.Text = itemID; } protected void btn_SetItemSelect_Click(object sender, EventArgs e) { //设置下拉列表框的选项 string itemID = this.txt_SetID.TextTrimNone; this.lst_Area.SetSelectedValue(itemID); }
protected void Page_Load(object sender, EventArgs e) { DataAccessLibrary dal = DALFactory.CreateDAL(); string sql = @"SELECT AreaID AS id, AreaName AS txt FROM Base_Area WHERE (AreaCode LIKE '__0000') SELECT ParentID,AreaID AS id, AreaName AS txt FROM Base_Area WHERE (AreaCode LIKE '____00') AND (AreaCode NOT LIKE '__0000') SELECT ParentID,AreaID AS id, AreaName AS txt FROM Base_Area WHERE (AreaCode NOT LIKE '__0000') AND (AreaCode NOT LIKE '____00') "; DataSet ds = dal.ExecuteFillDataSet(sql); this.lst_Area.DataSource = ds; this.lst_Area.DataBind(); }
if (!Page.IsPostBack) { //6,568,572 是“辽宁省,抚顺市,望花区”对于的ID //实际项目中,是从数据库里获取,然后设置,这里只是一个实例 this.lst_Area.SetSelectedValue("6,568,572"); }
protected virtual void SetHTML() { //一行里,下拉列表框前面加说明的方法 string[] html = new string[6]; html[0] = "省份:"; html[2] = "城市:";