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(); } } }
  • 相关阅读:
    PyQt(Python+Qt)学习随笔:containers容器类部件QStackedWidget重要方法介绍
    什么叫工业4.0,这篇接地气的文章终于讲懂了
    怎样 真正认识一个 人
    华为的绩效管理:减人、增 效、加薪
    羽毛球战术
    魔方教程
    员工培养:事前指导,事后纠正
    一把手瞄准哪里,核心竞争力就在哪里
    海尔的五次战略变革
    如何提高基层员工的执行力
  • 原文地址:https://www.cnblogs.com/janeaiai/p/10612917.html
Copyright © 2011-2022 走看看