码迷,mamicode.com
首页 > Web开发 > 详细

Web TreeView 加载级联数据

时间:2015-01-04 16:53:30      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                dt = BLL.GetTable();
                LoadLYRProperties(0, null);
            }
        }

        private DataTable dt = null;
        public void Load(int FID, TreeNode pNode)
        {
            DataView dvTree = new DataView(dt);
            //过滤ParentID,得到当前的所有子节点
            dvTree.RowFilter = "[FID] = " + FID;
            foreach (DataRowView Row in dvTree)
            {
                TreeNode root = new TreeNode();
                if (pNode == null)
                {   

                    root.Text = Row["NAME"].ToString();
                    tvLyrProperties.Nodes.Add(root);
                    root.Expanded = true;
                    root.Value = Row["ID"].ToString();
                    LoadLYRProperties(Int32.Parse(Row["ID"].ToString()), root);    //递归
                }
                else
                {   //添加当前节点的子节点
                    TreeNode subroot = new TreeNode();
                    subroot.Text = Row["NAME"].ToString();
                    pNode.ChildNodes.Add(subroot);
                    subroot.Expanded = true;
                    subroot.Value = Row["ID"].ToString();
                    LoadLYRProperties(Int32.Parse(Row["ID"].ToString()), subroot);    
                }
            }
        }

 

Web TreeView 加载级联数据

标签:

原文地址:http://www.cnblogs.com/wjshan0808/p/4201397.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!