treeView

        /// <summary>
        /// 绑定父节点数据
        /// </summary>
        private void BindData()
        {
            //获取到父节点信息
            var parentNodes = ComRole.ComBill.GetDepartMentDendrogram(1, this.ComUserId);
            if (parentNodes.Any())
            {

                foreach (var pNodes in parentNodes)
                {
                    pNodes.ComUserInfo = new ComUserInfo();
                    TreeNode node = new TreeNode();
                    node.Text = pNodes.departmentName;
                    node.Value = pNodes.identify.ToString();
                    treeDepart.Nodes.Add(node);
                    BindChildData(node, Convert.ToInt64(pNodes.identify));
                }
            }
            iframes.Attributes.Add("src", "ComDeptContentPage.aspx?id=170");
        }



        /// <summary>
        /// 绑定子节点
        /// </summary>
        /// <param name="parentId"></param>
        private void BindChildData(TreeNode nd, long parentId)
        {
            //获取子节点信息
            var childNodes = ComRole.ComBill.GetDepartMentDendrogram(parentId, this.ComUserId);
            if (childNodes.Any())
            {
                foreach (var childNode in childNodes)
                {
                    TreeNode tn = new TreeNode();
                    tn.Text = childNode.departmentName;
                    tn.Value = childNode.identify.ToString();
                    nd.ChildNodes.Add(tn);
                    BindChildData(tn, Convert.ToInt64(childNode.identify));
                }
            }
        }

posted @ 2012-05-16 17:39  Mancy  阅读(172)  评论(0编辑  收藏  举报