Below you will find pages that utilize the taxonomy term “Treeview”
Posts
read more
TreeNode
Ibland vill man visa data i TreeView. Här är ett litet exempel på koden:
using (SPWeb web = SPContext.Current.Web)
{
foreach (SPWeb topWeb in web.GetSubwebsForCurrentUser())
{
TreeNode tn = new TreeNode(topWeb.Name);
tn.NavigateUrl = topWeb.ServerRelativeUrl;
this.treeviewProjects.Nodes.Add(tn);
if (topWeb.Webs.Count > 0)
{
foreach (SPWeb subWeb in topWeb.GetSubwebsForCurrentUser())
{
TreeNode childNode = new TreeNode(subWeb.Name);
childNode.NavigateUrl = subWeb.ServerRelativeUrl;
tn.ChildNodes.Add(childNode);
subWeb.Dispose();
}
}
topWeb.Dispose();
}
}