Bobby Underwood

Bobby Underwood

  • NA
  • 2
  • 11.4k

Treeview in C# - trying to get children from sitecore to the webapp

Oct 4 2011 12:03 AM
try
            {
                masterDb = Factory.GetDatabase("master");


                Sitecore.Data.Database masterdb = Sitecore.Configuration.Factory.GetDatabase("master");
                Sitecore.Data.Items.Item srpackshome = masterdb.GetItem("/sitecore/content/home/Sports Recreation/Packs");
                Sitecore.Collections.ChildList children = srpackshome.Children;


                foreach (Sitecore.Data.Items.Item child in srpackshome.GetChildren())
                {
                   
                    TreeNode srPacksItem = new TreeNode(child.Name.Substring(child.Name.LastIndexOf(Path.DirectorySeparatorChar)+1));
                   
                    //TreeNode srPacksItem = new TreeNode(srpackshome.Name.Substring(srpackshome.Name.LastIndexOf(Path.DirectorySeparatorChar)+1));
                    treeSR.Nodes.Add(srPacksItem);
                }




---------------------------
using the above code I am trying to pull information from Sitecore and into the Web application to put the content into the treeview nodes.
The treeview consists of 4 levels. I am just trying to get the childrens children in from sitecore. The children will be static and I am referencing their folder in sitecore to pull their children into the application. It is not connecting.

Is there anyone familiar with sitecore that could help?

Answers (2)