private void BindData() { // TODO: NLevels number of items is not currently used // TODO: figure out how to get the treeview to use the sorted datatable // Removed caching because heirarchy lost great-grandchildren and lower after coming back out of the cache var root = ItemRelationship.GetAllChildrenNLevels(this.ItemId, this.numberOfLevels, -1, this.PortalId); // GetAllChildrenNLevels gives back a tree with two root nodes, we only need one root = root.FirstNode; // add the parent category to the list first. if (this.showParentItem) { Category parentItem = Category.GetCategory(this.ItemId, this.PortalId); if (parentItem != null) { var parentItemNode = new TreeNode(parentItem.Name) { Tag = parentItem.ItemId }; foreach (TreeNode node in root.Nodes) { parentItemNode.Nodes.Add(node); } root = new TreeNode(); root.Nodes.Add(parentItemNode); } } this.FillNLevelList(root, this.phNLevels); }
private void BindData() { //TODO: NLevels number of items is not currently used //ToDO: figure out how to get the treeview to use the sorted datatable string cacheKey = Utility.CacheKeyPublishCategoryNLevels + ItemId; // +"PageId"; var root = DataCache.GetCache(cacheKey) as System.Windows.Forms.TreeNode; if (root == null) { root = ItemRelationship.GetAllChildrenNLevels(ItemId, nLevels, -1, PortalId); if (root != null) { DataCache.SetCache(cacheKey, root, DateTime.Now.AddMinutes(CacheTime)); Utility.AddCacheKey(cacheKey, PortalId); } } //add the parent category to the list first. if (showParentItem) { Category parentItem = Category.GetCategory(ItemId, PortalId); #region showparent if (parentItem != null) { phNLevels.Controls.Add(new LiteralControl("<ul>")); phNLevels.Controls.Add(new LiteralControl("<li>")); var hlParent = new HyperLink(); if (parentItem.Disabled == false) { hlParent.NavigateUrl = GetItemLinkUrl(parentItem.ItemId); } hlParent.Text = parentItem.Name; if (highlightCurrentItem) { int itemId;//=0; object o = Request.QueryString["ItemId"]; if (o != null && int.TryParse(o.ToString(), out itemId)) { if (itemId == parentItem.ItemId) { hlParent.CssClass = HighlightCssClass; } } } phNLevels.Controls.Add(hlParent); phNLevels.Controls.Add(new LiteralControl("</li>")); FillNLevelList(root, phNLevels); phNLevels.Controls.Add(new LiteralControl("</ul>")); } else { FillNLevelList(root, phNLevels); } #endregion } else { FillNLevelList(root, phNLevels); } }