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()));
                }
            }
        }
  • 相关阅读:
    BFPRT算法O(n)解决第k小的数
    Manacher练习
    KMP全家桶练习
    Codeforces Round #552 (Div. 3)
    Manacher's Algorithm
    poj 2559 (单调栈)
    单调队列
    单调栈
    multiset用法
    poj3660 Cow Contest(Floyd-Warshall方法求有向图的传递闭包)
  • 原文地址:https://www.cnblogs.com/enych/p/7845381.html
Copyright © 2011-2022 走看看