CSS Adapted Treeview control displaying all nodes on page load

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>
0
cmssken1
12/17/2007 3:26:15 PM
asp.net.css-control-adapters 905 articles. 0 followers. Follow

2 Replies
683 Views

Similar Articles

[PageSpeed] 49

 I've managed to get the nodes to expand correctly by adding myNode.Expanded = "false" on the inital load, but this had made the list item a URL now. How can I remove this url so I can click the name of the category and have the list expand without posting back to the server?

0
cmssken1
12/17/2007 4:09:22 PM

Can't u use the Staticdisplaylevels property of the treeview control? It limits the number of menulevels that are fully expanded 


Hope this helps !
Rinze Cats

---------
please select 'mark as answer' if this post helped you!
0
Rinze
1/2/2008 8:32:15 PM
Reply: