前台代码 复制代码 代码如下: 后台代码: 复制代码 代码如下: private void BindGrid() { DataTable mytable = menuTableBll.GetAllList().Tables[0]; //获取数据 CreateTree(mytable, TreeView1.Nodes, "0"); } private void CreateTree(DataTable dtNodeSets, TreeNodeCollection node, string parent_id) { DataView dvList = new DataView(dtNodeSets); dvList.RowFilter = "MeunParentId =" + parent_id; TreeNode nodeTemp; foreach (DataRowView dv in dvList) { nodeTemp = new TreeNode(); nodeTemp.Text = dv["MenuName"].ToString(); nodeTemp.Expanded = true; nodeTemp.ToolTip = dv["MeunId"].ToString(); node.Add(nodeTemp); CreateTree(dtNodeSets, nodeTemp.ChildNodes, dv["MeunId"].ToString()); } } 09-14 02:05