zoukankan      html  css  js  c++  java
  • 二三级下拉菜单

    if (!Page.IsPostBack)
            {
                string sql = "select * from InfoType";
                DataTable dt = SqlHelp.ExecuteDataTable(sql);
                string js = "",ss = "";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["parenttypeid"].ToString()=="")
                    {
                        js=dt.Rows[i]["typeid"].ToString();
                        DropDownList1.Items.Insert(i, new ListItem(dt.Rows[i]["tyepname"].ToString(), ""));
                    }
                    else
                    {
                        if (dt.Rows[i]["parenttypeid"].ToString()==js)
                        {
                             ss = "+";
                        }
                        else
                        {
                            ss = "++";
                        }
                        DropDownList1.Items.Insert(i, new ListItem(ss + dt.Rows[i]["tyepname"].ToString(), ""));
                    }
                }
            }

     private void DLbinddata()
        {
            string sql = "select * from InfoType"; //查询信息类型 下拉列表绑定
            DataTable dt = SqlHelp.ExecuteDataTable(sql);
            string js = "", ss = "";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["parenttypeid"].ToString() == "") //判断每一行parenttypeid=空的 
                {
                    js = dt.Rows[i]["typeid"].ToString();//获取这个typeid
    
                    DropDownList1.Items.Insert(i, new ListItem(dt.Rows[i]["tyepname"].ToString(), dt.Rows[i]["typeid"].ToString()));
                }
                else
                {
                    if (dt.Rows[i]["parenttypeid"].ToString() == js) // 判断子级的父级id = 这个父级id
                    {
                        ss = " ├";
                    }
                    else
                    {
                        ss = "  ├";
                    }
                    DropDownList1.Items.Insert(i, new ListItem(ss + dt.Rows[i]["tyepname"].ToString(), dt.Rows[i]["typeid"].ToString()));
                }
            }
        }
  • 相关阅读:
    前端精选文摘:BFC 神奇背后的原理
    Linux下关闭node应用
    CentOS7配置Nodejs环境安装记录
    Express4+Mongodb极简入门实例
    Centos7 防火墙设置
    如何解决Linux内网环境依赖问题
    Centos7 显卡驱动安装教程
    ios自动化WebDriverAgent测试报错
    Windows版sudo 以管理员发送运行CMD
    adb常用命令
  • 原文地址:https://www.cnblogs.com/enych/p/7845381.html
Copyright © 2011-2022 走看看