陋室铭
永远也不要停下学习的脚步(大道至简至易)

            TreeNode[] myNodes = new TreeNode[100];
            for (int i = 0; i < myNodes.Length; i++)
            {
               myNodes[i] = new TreeNode();
            }


            for (int i = 0; i < dt.Rows.Count; i++)
            {
               int NodeId = (int)dt.Rows[i]["ModuleID"];
                int MyParent = (int)dt.Rows[i]["Parent_int"];

                if (MyParent != 0)
                {
                    myNodes[NodeId].Text = dt.Rows[i]["Content_nva"].ToString();
                    myNodes[NodeId].NavigateUrl = dt.Rows[i]["Url_nva"].ToString().Trim();
                    myNodes[NodeId].ImageUrl = "~/Images/edit.gif";
                    myNodes[NodeId].Target = "main";
                    myNodes[MyParent].ChildNodes.Add(myNodes[NodeId]);
                }
                else
                {
                    myNodes[NodeId].Text = dt.Rows[i]["Content_nva"].ToString();
                    myNodes[NodeId].SelectAction = TreeNodeSelectAction.None;
                    TreeView1.Nodes.Add(myNodes[NodeId]);
                }
            }

posted on 2006-11-28 11:19  宏宇  阅读(420)  评论(0编辑  收藏  举报