zoukankan      html  css  js  c++  java
  • ASP DROPDOWN 三级联动最好用

          <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
                                </asp:ScriptManager>
                                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                    <ContentTemplate>
                                        <asp:DropDownList ID="dpSheng" runat="server" Width="120px"
                                            AutoPostBack="true" OnSelectedIndexChanged="dpProvince_SelectedIndexChanged" />
                                        <asp:DropDownList ID="dpShi" runat="server" AutoPostBack="true" Width="120px"
                                            OnSelectedIndexChanged="dpCity_SelectedIndexChanged" />
                                        <asp:DropDownList ID="dpXian" runat="server" AutoPostBack="false" Width="120px"/>
                                        <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                                            <ProgressTemplate>
                                                正在加载...
                                            </ProgressTemplate>
                                        </asp:UpdateProgress>
                                    </ContentTemplate>
                                    <%-- 异步回送防止整页刷新 --%>
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="dpSheng" EventName="SelectedIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="dpShi" EventName="SelectedIndexChanged" />
                                    </Triggers>
                                </asp:UpdatePanel>
     protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindSheng();
                BindShi();
                BindXian();
            }
        }
    
        private void BindSheng()
        {
    //获取省数据 dpSheng.DataSource
    = baseParameterBll.GetModelDataList("par_type=0 and par_parent='0'"); dpSheng.DataValueField = "par_id"; dpSheng.DataTextField = "par_name"; dpSheng.DataBind(); dpSheng.Items.Insert(0, new ListItem("选择省份", "-")); } private void BindShi() { string sheng = dpSheng.SelectedValue; if (sheng != "-") { dpShi.DataSource = baseParameterBll.GetModelDataList("par_type=0 and par_parent='" + sheng + "'"); dpShi.DataValueField = "par_id"; dpShi.DataTextField = "par_name"; dpShi.DataBind(); } dpShi.Items.Insert(0, new ListItem("选择市", "-")); } private void BindXian() { string shi = dpShi.SelectedValue; if (shi != "-") { dpXian.DataSource = baseParameterBll.GetModelDataList("par_type=0 and par_parent='" + shi + "'"); dpXian.DataValueField = "par_id"; dpXian.DataTextField = "par_name"; dpXian.DataBind(); } dpXian.Items.Insert(0, new ListItem("选择区", "-")); } protected void dpProvince_SelectedIndexChanged(object sender, EventArgs e) { dpShi.Items.Clear(); BindShi(); dpXian.Items.Clear(); BindXian(); } protected void dpCity_SelectedIndexChanged(object sender, EventArgs e) { dpXian.Items.Clear(); BindXian(); } } }
  • 相关阅读:
    在360工作的这几天
    ISBN号码
    poj 3667 Hotel
    命令模式之2 Invoker Vs. Client
    vehicle time series data analysis
    JSON之三:获取JSON文本并解释(以google的天气API为例)
    创建型模式--工厂方法模式
    OpenStack Heat总结之:Icehouse中通过Heat+Ceilometer实现Autoscaling
    MyEclipse10 中增加svn插件
    activitie用户手册
  • 原文地址:https://www.cnblogs.com/janeaiai/p/10612917.html
Copyright © 2011-2022 走看看