日期:2014-05-18 浏览次数:20616 次
private void InitTree(TreeNodeCollection Nds) { DataView dvroles = new DataView(); TreeNode tmpNd; string strRID; dvroles.Table = SubjTable; dvroles.RowFilter = " PID=ID"; foreach (DataRowView drvrole in dvroles) { strRID = drvrole["ID"].ToString(); tmpNd = new TreeNode(); tmpNd.Value = drvrole["ID"].ToString(); tmpNd.Text = drvrole["Name"].ToString(); Nds.Add(tmpNd); AddChildren(tmpNd.ChildNodes, strRID); } } private void AddChildren(TreeNodeCollection Nds, string ParentId) { DataView dvroles = new DataView(); TreeNode tmpNd; string strRID; dvroles.Table = SubjTable; dvroles.RowFilter = " PID IS NOT NULL AND PID=" + ParentId; foreach (DataRowView drvrole in dvroles) { strRID = drvrole["ID"].ToString(); tmpNd = new TreeNode(); tmpNd.Value = drvrole["ID"].ToString(); tmpNd.Text = drvrole["Name"].ToString(); Nds.Add(tmpNd); AddChildren(tmpNd.ChildNodes, strRID); } }
------解决方案--------------------
发我消息.我发给你