SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Any idea to hide non-site items in the Sharepoint 2010 tree view control? Or the only chance is to develop our own control and integrate it on the master page?

there's this link but it doesn't seems so quite simple.


Updated: Actually it works fine in masterpages, but only in blank sites. anyone knows why?

share|improve this question
what exactly do you want to display/hide.. the article looks simple enough. – Ashish Patel Jan 26 '12 at 14:51
hide all site content in tree view control, leaving only the inherent Sites and Subsites below it. – fallout Jan 26 '12 at 15:40
check my answer below – Ashish Patel Jan 26 '12 at 16:14
up vote 4 down vote accepted

If you want to just show Sites and Subsites below it, you can setup the Data Source like this:

 <SharePoint:SPHierarchyDataSourceControl runat="server" ID="TreeViewDataSource"  
        IncludeDiscussionFolders="false" ShowListChildren="false" ShowDocLibChildren="false"
        ShowFolderChildren="false" RootContextObject="Web" />

And use above data source with the treeview as shown below:

  <SharePoint:SPTreeView runat="server" ID="WebTreeView" ShowLines="false" DataSourceID="TreeViewDataSource"
        ExpandDepth="0" SelectedNodeStyle-CssClass="ms-tvselected" NodeStyle-CssClass="ms-navitem"
        NodeStyle-HorizontalPadding="2" SkipLinkText="" NodeIndent="12" ExpandImageUrl="/_layouts/images/MDNCollapsed.png"
        ExpandImageUrlRtl="/_layouts/images/tvclosedrtl.png" CollapseImageUrl="/_layouts/images/MDNExpanded.png"
        CollapseImageUrlRtl="/_layouts/images/tvopenrtl.png" NoExpandImageUrl="/_layouts/images/tvblank.gif"


I tested above in custom application page and it apperas as below:

enter image description here

share|improve this answer
It works, for real. thanks. But actually I was trying to get the same result throw the masterpage and that is what I'm not getting to. – fallout Jan 30 '12 at 8:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.