标签:
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); } } }
标签:
原文地址:http://www.cnblogs.com/wjshan0808/p/4201397.html