zoukankan      html  css  js  c++  java
  • .NET ----- 多级联动

     联动

    <tr>
    <td width="20%" align="right" bgcolor="#F5F5F5">报考地区:</td>
    <td align="left" bgcolor="#FFFFFF" width="30%">
    <asp:DropDownList ID="ddlXueLi_Area_4501_Code" runat="server" width="121px" AutoPostBack="true" OnSelectedIndexChanged="ddlXueLi_Area_4501_Code_SelectedIndexChanged"></asp:DropDownList></td>
    
    <td width="20%" align="right" bgcolor="#F5F5F5">报考层次:</td>
    <td align="left" bgcolor="#FFFFFF" width="30%">
    <asp:DropDownList ID="ddlXueLi_CengCi_4501_Code" runat="server" width="121px" AutoPostBack="true" OnSelectedIndexChanged="ddlXueLi_Area_4501_Code_SelectedIndexChanged"></asp:DropDownList></td>
    </tr>
    
    <tr>
    <td width="20%" align="right" bgcolor="#F5F5F5">报考学校:</td>
    <td align="left" bgcolor="#FFFFFF" width="30%">
    <asp:DropDownList ID="ddlXueLi_School_4501_Code" runat="server" width="121px" AutoPostBack="true" OnSelectedIndexChanged="ddlXueLi_Area_4501_Code_SelectedIndexChanged"></asp:DropDownList></td>
    
    <td width="20%" align="right" bgcolor="#F5F5F5">报考专业:</td>
    <td align="left" bgcolor="#FFFFFF" width="30%">
    <asp:DropDownList ID="ddlXueLi_ZhuanYe_4501_Code" runat="server" width="121px" AutoPostBack="true" OnSelectedIndexChanged="ddlXueLi_Area_4501_Code_SelectedIndexChanged"></asp:DropDownList></td>
    
    </tr>

    获取第一级的,然后通过前面的 函数调用后面的方法

        {//报考地区
                List<ITEM.Model.qdCnt4.FourCollsType> mList = _bllTypeColls.Get_Ex_FourCollsTypeListByIDLevel("TypeCollCode,TypeCollName", base.EnterpriseGuid, 4501, 1, (float)_iFlag);
                this.ddlXueLi_Area_4501_Code.DataTextField = "TypeCollName";
                this.ddlXueLi_Area_4501_Code.DataValueField = "TypeCollCode";
                this.ddlXueLi_Area_4501_Code.DataSource = mList;
                this.ddlXueLi_Area_4501_Code.DataBind();
                this.ddlXueLi_Area_4501_Code.Items.Insert(0, new ListItem());
            }

    方法

     protected void ddlXueLi_Area_4501_Code_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddl = (DropDownList)sender;
            if (ddl.ID == "ddlXueLi_Area_4501_Code")
            {
                string sCode = this.ddlXueLi_Area_4501_Code.SelectedValue;
                if (sCode != string.Empty)
                {
                    List<ITEM.Model.qdCnt4.FourCollsType> mList = _bllTypeColls.Get_Ex_FourCollsTypeList_CodeDown("TypeCollCode,TypeCollName", base.EnterpriseGuid, 4501, sCode, 2, (float)_iFlag);
                    this.ddlXueLi_CengCi_4501_Code.DataTextField = "TypeCollName";
                    this.ddlXueLi_CengCi_4501_Code.DataValueField = "TypeCollCode";
                    this.ddlXueLi_CengCi_4501_Code.DataSource = mList;
                    this.ddlXueLi_CengCi_4501_Code.DataBind();
                    this.ddlXueLi_CengCi_4501_Code.Items.Insert(0, new ListItem());
                }
            }
            else if (ddl.ID == "ddlXueLi_CengCi_4501_Code")
            {
                string sCode = this.ddlXueLi_CengCi_4501_Code.SelectedValue;
                if (sCode != string.Empty)
                {
                    List<ITEM.Model.qdCnt4.FourCollsType> mList = _bllTypeColls.Get_Ex_FourCollsTypeList_CodeDown("TypeCollCode,TypeCollName", base.EnterpriseGuid, 4501, sCode, 3, (float)_iFlag);
                    this.ddlXueLi_School_4501_Code.DataTextField = "TypeCollName";
                    this.ddlXueLi_School_4501_Code.DataValueField = "TypeCollCode";
                    this.ddlXueLi_School_4501_Code.DataSource = mList;
                    this.ddlXueLi_School_4501_Code.DataBind();
                    this.ddlXueLi_School_4501_Code.Items.Insert(0, new ListItem());
                }
            }
            else if (ddl.ID == "ddlXueLi_School_4501_Code")
            {
                string sCode = this.ddlXueLi_School_4501_Code.SelectedValue;
                if (sCode != string.Empty)
                {
                    List<ITEM.Model.qdCnt4.FourCollsType> mList = _bllTypeColls.Get_Ex_FourCollsTypeList_CodeDown("TypeCollCode,TypeCollName", base.EnterpriseGuid, 4501, sCode, 4, (float)_iFlag);
                    this.ddlXueLi_ZhuanYe_4501_Code.DataTextField = "TypeCollName";
                    this.ddlXueLi_ZhuanYe_4501_Code.DataValueField = "TypeCollCode";
                    this.ddlXueLi_ZhuanYe_4501_Code.DataSource = mList;
                    this.ddlXueLi_ZhuanYe_4501_Code.DataBind();
                    this.ddlXueLi_ZhuanYe_4501_Code.Items.Insert(0, new ListItem());
                }
            }
            else if (ddl.ID == "ddlXueLi_ZhuanYe_4501_Code")
            {
                string sCode = this.ddlXueLi_ZhuanYe_4501_Code.SelectedValue;
                if (sCode != string.Empty)
                {
                    ITEM.Model.qdCnt4.FourCollsType m = _bllTypeColls.Get_Ex_Model_FourCollsTypeListByCollCode("TypeCollCode,TypeCollName", base.EnterpriseGuid, 4501, sCode, (float)_iFlag);
                    this.tbPrice_zhidao.Text = m.Ext01;
                }
            }
        }

    保存的时候赋值

       gbaoming_xueli.XueLi_Area_4501_Code = this.ddlXueLi_Area_4501_Code.SelectedValue;
            gbaoming_xueli.XueLi_Area_4501_Name = this.ddlXueLi_Area_4501_Code.SelectedItem.Text;
            gbaoming_xueli.XueLi_CengCi_4501_Code = this.ddlXueLi_CengCi_4501_Code.SelectedValue;
            gbaoming_xueli.XueLi_CengCi_4501_Name = this.ddlXueLi_CengCi_4501_Code.SelectedItem.Text;
            gbaoming_xueli.XueLi_School_4501_Code = this.ddlXueLi_School_4501_Code.SelectedValue;
            gbaoming_xueli.XueLi_School_4501_Name = this.ddlXueLi_School_4501_Code.SelectedItem.Text;
            gbaoming_xueli.XueLi_ZhuanYe_4501_Code = this.ddlXueLi_ZhuanYe_4501_Code.SelectedValue;
            gbaoming_xueli.XueLi_ZhuanYe_4501_Name = this.ddlXueLi_ZhuanYe_4501_Code.SelectedItem.Text;
            if (gbaoming_xueli.XueLi_Area_4501_Code == string.Empty)
            {
                WebMessageBox1.MessageBox_tishi(700, 300, 200, 300, "请选择报考地区");
                return;
            }
            if (gbaoming_xueli.XueLi_CengCi_4501_Code == string.Empty)
            {
                WebMessageBox1.MessageBox_tishi(700, 300, 200, 300, "请选择报考层次");
                return;
            }
    
            if (gbaoming_xueli.XueLi_School_4501_Code == string.Empty)
            {
                WebMessageBox1.MessageBox_tishi(700, 300, 200, 300, "请选择报考院校");
                return;
            }
            if (gbaoming_xueli.XueLi_ZhuanYe_4501_Code == string.Empty)
            {
                WebMessageBox1.MessageBox_tishi(700, 300, 200, 300, "请选择专业名称");
                return;
            }

    修改展示使:

                this.ddlXueLi_Area_4501_Code.SelectedValue = gbaoming_xueli.XueLi_Area_4501_Code;
                ddlXueLi_Area_4501_Code_SelectedIndexChanged(this.ddlXueLi_Area_4501_Code, new EventArgs());
    
                this.ddlXueLi_CengCi_4501_Code.SelectedValue = gbaoming_xueli.XueLi_CengCi_4501_Code;
                ddlXueLi_Area_4501_Code_SelectedIndexChanged(this.ddlXueLi_CengCi_4501_Code, new EventArgs());
    
                this.ddlXueLi_School_4501_Code.SelectedValue = gbaoming_xueli.XueLi_School_4501_Code;
                ddlXueLi_Area_4501_Code_SelectedIndexChanged(this.ddlXueLi_School_4501_Code, new EventArgs());
    
                this.ddlXueLi_ZhuanYe_4501_Code.SelectedValue = gbaoming_xueli.XueLi_ZhuanYe_4501_Code;
                ddlXueLi_Area_4501_Code_SelectedIndexChanged(this.ddlXueLi_ZhuanYe_4501_Code, new EventArgs());

    还有个

                this.ddlXueLi_Area_4501_Code.Enabled = false;
                this.ddlXueLi_Area_4501_Code.Attributes.Add("style", "color:#888888;");//所属省
    
                this.ddlXueLi_CengCi_4501_Code.Enabled = false;
                this.ddlXueLi_CengCi_4501_Code.Attributes.Add("style", "color:#888888;");//报考层次
    
                this.ddlXueLi_School_4501_Code.Enabled = false;
                this.ddlXueLi_School_4501_Code.Attributes.Add("style", "color:#888888;");//报考层次
    
                this.ddlXueLi_ZhuanYe_4501_Code.Enabled = false;
                this.ddlXueLi_ZhuanYe_4501_Code.Attributes.Add("style", "color:#888888;");//报考层次

    使用会掉函数调用

  • 相关阅读:
    装饰者模式和适配器模式
    java 中获得 资源文件方法
    在windows 上统计git 代码量
    Linux-静态库生成
    Redis-Redi事务注意事项
    Linux-使用 yum 升级 gcc 到 4.8
    Linux-配置虚拟IP
    PHP-PSR-[0-4]代码规范
    Linux-/etc/rc.local 或 service 中使用 sudo -u xxx cmd 执行失败(sorry, you must have a tty to run sudo)解决办法
    Linux-系统负载
  • 原文地址:https://www.cnblogs.com/obge/p/13093053.html
Copyright © 2011-2022 走看看