• C# treeview绑定


    protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    bindTree();
                }
            }
            private void bindTree()
            {
                ALIYUN_PIC.BLL.Folder_oper_BLL bll = new Folder_oper_BLL();
                
                DataTable dt = bll.PIC_Bind();//得到需要的datatable
                this.FillNode(dt, null);
            }
            private void FillNode(DataTable dt, TreeNode node)
            {
                DataView dv = new DataView(dt);
                if (node == null)    //根结点
                {
                    dv.RowFilter = "PARENT_NODE='0'";  //筛选到根结点的所有子节点
                }
                else  //不是根结点
                {
                    dv.RowFilter = "PARENT_NODE='" + node.Value + "'";   //筛选对应节点的所有子节点
                }
                foreach (DataRowView drv in dv)   //遍历填充节点的所有子节点,如果传入的节点node为叶子节点,遍历要退出,不再进行递归
                {
                    TreeNode no = new TreeNode(drv["NODE_NAME"].ToString(), drv["id"].ToString());
                    FillNode(dt, no);  //填充no节点的子节点
                    if (node == null)
                    {                  
                        this.PIC_TREE.Nodes.Add(no);
                    }
                    else
                    {
                        node.ChildNodes.Add(no);
                    }
                }
            }

  • 相关阅读:
    Iterator 迭代器
    Collection-List
    Collection-Set
    Collection
    多线程
    面向对象<高级>知识点
    链表
    面向对象<基础>知识点
    三层架构和MVC模式详解
    impala为什么比hive快
  • 原文地址:https://www.cnblogs.com/sg1991/p/4158118.html
Copyright © 2020-2023  润新知