zoukankan      html  css  js  c++  java
  • 无限级目录

    //绑定所有目录
        public static void Bind_list(DropDownList DropDownList1)
        
    {
            DropDownList1.Items.Clear();
            
    string sql = "SELECT list_id,list_name,list_parent FROM list";
            DataTable dt 
    = DataBase.getDataTable(sql);  //根据SQL语句获取DataTable值
            Bind_list(DropDownList1,dt, "0"0);
        }


        
    private static void Bind_list(DropDownList DropDownList1, DataTable dt, string parent, int grade)
        
    {
            DataRow[] dr 
    = dt.Select("list_parent=" + parent, "list_id asc");
            
    if (dr.Length > 0)
            
    {
                
    int grade1 = grade + 1;
                
    foreach (DataRow row in dr)
                
    {
                    ListItem li 
    = new ListItem();
                    li.Text 
    = "";
                    
    for (int i = 0; i < grade; i++)
                    
    {
                        li.Text 
    += " ";
                    }

                    li.Text 
    += "" + row[1].ToString();
                    li.Value 
    = row[0].ToString();
                    DropDownList1.Items.Add(li);
                    Bind_list(DropDownList1,dt, row[
    0].ToString(), grade1);
                }

            }

        }
  • 相关阅读:
    Cookie存储在哪里
    save the transient instance before flushing错误解决办法
    hibernate中简单的增删改查
    hibernate中get和load的区别
    使用Linux命令修改数据库密码
    配置solrcloud
    如何确定Redis集群中各个节点的主从关系
    解决Eclipse Debug 断点调试的source not found问题
    .NET框架
    ORM框架
  • 原文地址:https://www.cnblogs.com/chjf2008/p/1277969.html
Copyright © 2011-2022 走看看