• DropDownList二级无刷新功能实现


    DropDownList二级无刷新功能实现


    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
    <Triggers>
    <!--注意这里是SelectedIndexChanged 不是OnSelectedIndexChanged事件名-->
    <asp:AsyncPostBackTrigger ControlID="sclassbig" EventName="SelectedIndexChanged" />
    </Triggers>
    <ContentTemplate>

    <asp:DropDownList ID="sclassbig" AutoPostBack="true" OnSelectedIndexChanged="select_change"
    runat="server">
    <asp:ListItem>保洁</asp:ListItem>
    <asp:ListItem>钟点工</asp:ListItem>
    </asp:DropDownList>

    <asp:DropDownList ID="sclasssml" AutoPostBack="true" runat="server">
    </asp:DropDownList>

    </ContentTemplate>
    </asp:UpdatePanel>


    cs 代码

    /// <summary>
    /// 绑定服务小类
    /// </summary>
    protected void smlbd()
    {
    string bigStr = "保洁";//默认服务选项
    DataTable dt = getSql("select sclasssml from sclass where sclassbig='"+bigStr+"'");
    sclasssml.DataSource = dt;
    sclasssml.DataTextField = "sclasssml";
    sclasssml.DataValueField = "sclasssml";
    sclasssml.DataBind();
    }
    /// <summary>
    /// 大类联动小类
    /// </summary>
    protected void select_change(object sender, EventArgs e)
    {
    string bigStr = sclassbig.SelectedValue;
    DataTable dt = getSql("select sclasssml from sclass where sclassbig='" + bigStr + "'");
    sclasssml.DataSource = dt;
    sclasssml.DataTextField = "sclasssml";
    sclasssml.DataValueField = "sclasssml";
    sclasssml.DataBind();
    //sclasssml.Items.Insert(0, "--请选择--");
    //sclasssml.Items[0].Value = "0";

    }
  • 相关阅读:
    Java synchronized详解
    How to Use Lambda Expressions in a Query
    生活工作记录
    SilverLight中的几何形状 (转)
    用CSS改变鼠标样式
    SCRUM 敏捷开发 基础及失败成功案例分析
    JavaScript Create GUID function
    数据结构排序
    JSON简介
    追逐所求,享受所有
  • 原文地址:https://www.cnblogs.com/cyjch/p/2340222.html
Copyright © 2020-2023  润新知