日期:2014-05-17 浏览次数:20519 次
private void InitTree(TreeNodeCollection Nds,int parentid) { DataView dv = new DataView(); TreeNode tmpNd = null; dv.Table = ds.Tables[0]; dv.RowFilter = String.Format("parentid={0}", parentid); foreach (DataRowView drv in dv) { tmpNd = new TreeNode(); tmpNd.Text = (string)drv["sortname"];//节点名称 tmpNd.NavigateUrl = String.Format("?id={0}", drv["id"]);//节点URL //tmpNd.ImageUrl = ""; //节点图片 if (parentid == 0) tmpNd.Expanded = true; else tmpNd.Expanded = false; Nds.Add(tmpNd); InitTree(Nds[Nds.Count - 1].ChildNodes, (int)drv["id"]); } }