[转载]DropDownList三级菜单联动源码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Insus.NET;

public partial class MultiDropDownListSelectDemo : System.Web.UI.Page
{
    Address objAddress = new Address();
    ListControlUtility objLcu = new ListControlUtility();
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Data_Binding();
        }
    }

    private void Data_Binding()
    {
        objLcu.DropDownListParse(this.DdlProvince, objAddress.GetProvince(), "ProvinceName", "ProvinceId", "--选择省--");

        this.DdlCity.Items.Add(new ListItem("--选择市--"));
        this.DdlDistrict.Items.Add(new ListItem("选择县或区"));

    }

    protected void DdlProvince_SelectedIndexChanged(object sender, EventArgs e)
    {
        string sltValue = this.DdlProvince.SelectedItem.Value;
        if (string.IsNullOrEmpty(sltValue))
        {
            sltValue = "0";
        }

        objLcu.DropDownListParse(this.DdlCity, objAddress.GetCityByProvince(sltValue), "CityName", "CityId", "--选择市--");
    }

    protected void DdlCity_SelectedIndexChanged(object sender, EventArgs e)
    { 
         string sltValue = this.DdlCity.SelectedItem.Value;
         if (string.IsNullOrEmpty(sltValue))
         {
             sltValue = "0";
         }

        objLcu.DropDownListParse(this.DdlDistrict, objAddress.GetDistrictByCity(sltValue), "DistrictName", "DistrictId", "--选择县或区--");
    }
}

转载自http://www.cnblogs.com/insus/archive/2011/07/04/2097059.html

posted @ 2016-09-28 11:29  AaronBear  阅读(272)  评论(0编辑  收藏  举报