protected void Collections_PopulateNodes(object sender, FlyTreeNodeEventArgs e) { int collectionID = int.Parse(e.Node.Value); using (WindchimeEntities wce = new WindchimeEntities()) { var children = (from Collection c in wce.Collections where c.EntityID == collectionID select c.Children).First(); foreach (Collection c in children) { var node = new FlyTreeNode(c.Name, c.EntityID.ToString()); //node.ImageUrl = "~/Images/folder-small.png"; // if there are children out there, populate them later. if not, no point in confusing the user c.Children.Load(); if (c.Children.Count != 0) { node.PopulateNodesOnDemand = true; } else { node.PopulateNodesOnDemand = false; } e.Node.ChildNodes.Add(node); } } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } // fresh tree //Collections_tree.Nodes.Clear(); using (WindchimeEntities wce = new WindchimeEntities()) { // only want to display top level collections at the root level var topLevelCollections = from Collection c in wce.Collections where c.Parents.Count == 0 select c; foreach (Collection c in topLevelCollections) { var node = new FlyTreeNode(c.Name, c.EntityID.ToString()); //node.ImageUrl = "~/Images/folder-small.png"; // if there are children out there, populate them later. if not, no point in confusing the user c.Children.Load(); if (c.Children.Count != 0) { node.PopulateNodesOnDemand = true; } else { node.PopulateNodesOnDemand = false; } Collections_tree.Nodes.Add(node); } } }