Configure Dataview Webpart to display results from a centralized list regardless of what site level

If you need to deploy a customized dataview web-part (customized in SharePoint Designer) across multiple sites within a site collection this may be a good option particularly if you want each instance of the dataview web-part to query and render the data from a single list.  Useful anytime you want to store the data in a centralized location, customize the dataview web-part in SharePoint Designer, and upload to the web-part gallery for use on any subsite.    Applies to SharePoint 2010 and SharePoint 2007 and WSS as well. 


1) Convert your dataview web-part to XSLT in SharePoint Designer

2) Locate the SharePoint:SPDataSource control in code view

3) Locate the SelectCommand section and add the webs scope to your dataview web-parts SelectCommand directly preceding the select query:

SelectCommand=”<Webs Scope=’Recursive’></Webs>&lt;View&gt;&lt;Query&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;Order&quot;/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;/View&gt;”

4) Add or Modify the WebUrl parameter in your <SelectParameters> section of the datasource ontolr and update the DefaultValue to {sitecollectionroot}:

<asp:Parameter Name=”WebUrl” DefaultValue= “{sitecollectionroot} “/>

5) Save the page, open in browser and export dataview web-part to your computer.

6) From Site Action, Site Settings select the link to the webpart gallery and upload the web-part to the web part gallery or Import the web-part on any site page.

Exporting/Importing SharePoint webparts

Have fun.


<SharePoint:SPDataSource runat=”server” DataSourceMode=”List” SelectCommand=”<Webs Scope=’Recursive’></Webs>&lt;View&gt;&lt;Query&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;Order&quot;/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;/View&gt;” UseInternalName=”True” IncludeHidden=”True” ID=”datasource1″><SelectParameters><asp:Parameter DefaultValue=”{5942043E-EC50-41A2-8A06-513CA392FE65}” Name=”ListID”></asp:Parameter><asp:QueryStringParameter QueryStringField=”RootFolder” Name=”RootFolder” Type=”String”></asp:QueryStringParameter><asp:Parameter DefaultValue=”0″ Name=”StartRowIndex”></asp:Parameter><asp:Parameter DefaultValue=”0″ Name=”nextpagedata”></asp:Parameter><asp:Parameter DefaultValue=”100″ Name=”MaximumRows”></asp:Parameter><asp:Parameter Name=”WebUrl” DefaultValue=”{sitecollectionroot}”/>
</SelectParameters><UpdateParameters><asp:Parameter DefaultValue=”{5942043E-EC50-41A2-8A06-513CA392FE65}” Name=”ListID”></asp:Parameter>
</UpdateParameters><InsertParameters><asp:Parameter DefaultValue=”{5942043E-EC50-41A2-8A06-513CA392FE65}” Name=”ListID”></asp:Parameter>
</InsertParameters><DeleteParameters><asp:Parameter DefaultValue=”{5942043E-EC50-41A2-8A06-513CA392FE65}” Name=”ListID”></asp:Parameter>


2 thoughts on “Configure Dataview Webpart to display results from a centralized list regardless of what site level

  1. Unless I’m missing your goal here, you shouldn’t add the . That’s telling the DVWP to look across all of the Webs for source items when it sounds like you simply want to pull data from a single list in the root site of the Site Collection. At the very least it’ll be less efficient.


    • The goal for this particular use was to provide a mechanism to customize the built-in Links list as a dataview web-part, place in the web part gallery, and be able to drop on any site page in the site collection, regardless of what sub-web and access the data in the source list, again depending on the instance, from any other specific links list located throughout the entire site collection. No additional custom javascript, jquery, etc. to be maintained. I agree typically you wouldn’t scope the webs property of the SPSiteDataQuery object to be recursive throughout the site collection but in this case the deployment is limited so it is not a detriment to performance and the webs property is supported by SharePoint. Of course there are other options, this is just one demonstrating the availability of webs property. The crosslist scope is another built-in property with it’s own uses and implementation. Another option where scoping to the specific list URL I find use is the URL Protocol which have used for years, more recently in conjunction with LINQ TO XML and Silverlight-much more efficient and also more flexible and interactive UI than can be easily achieved with traditional client-side scripting. Previous posts on the topic on this blog including

      Of course with SharePoint 2010 a whole new array of options the the client-side OM etc. Found this usefull when my team developed an application on SP2010 alpha at the Office 10 Developer Kitchen at Microsoft. Using the client-side OM to pull data from SharePoint mysites from WPF. Fun stuff.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s