User-1883774565 posted
Hi. I have decided to use the adapted Treeview control for a project I am working on at the moment. All the control will do is display lists of categories and sub categories, and eventually products at the bottom level. When I load my page up, everything
is displayed, rather than the top level nodes. I have taken the control out and placed it in a small test project and exactly the same thing is happening. I am not using the App_Themes folder, I am linking directly to the CSS and Javascript files, and my CSS
Treeview Adapter is in it's own .dll file. My code is below. If anyone could give me some pointers and help me out that would be great. I am using C#.
1 namespace CSSAdaptersTest
2 {
3 using System;
4 using System.Data;
5 using System.Configuration;
6 using System.Collections;
7 using System.Web;
8 using System.Web.Security;
9 using System.Web.UI;
10 using System.Web.UI.WebControls;
11 using System.Web.UI.WebControls.WebParts;
12 using System.Web.UI.HtmlControls;
13 using Mando.Platform.ECommerce.ProductManagement;
14 using Mando.Platform.ECommerce.StoreManagement;
15
16 public partial class index : System.Web.UI.Page
17 {
18 protected void Page_Load(object sender, EventArgs e)
19 {
20
21 }
22
23 protected void PopulateNode(object sender, TreeNodeEventArgs e)
24 {
25 int categoryID = Convert.ToInt32(e.Node.Value);
26 Category myRootCategory = new Category(categoryID);
27 CategoryCollection myCategories = new CategoryCollection(myRootCategory.CategoryID);
28
29 if (myCategories.Count > 0)
30 {
31 foreach (Category myCategory in myCategories)
32 {
33 TreeNode myNode = new TreeNode(myCategory.Name, myCategory.CategoryID.ToString());
34 myNode.PopulateOnDemand = true;
35 myNode.SelectAction = TreeNodeSelectAction.Expand;
36 e.Node.ChildNodes.Add(myNode);
37 }
38 }
39 }
40 }
41 }
On my .aspx page, my treeview control is as follows:
<asp:TreeView ID="relatedVariants" runat="server" PopulateNodesFromClient="true" OnTreeNodePopulate="PopulateNode" EnableClientScript="true">
<Nodes>
<asp:TreeNode PopulateOnDemand="true" Text="Root" Value="48" SelectAction="Expand"></asp:TreeNode>
</Nodes>
</asp:TreeView>