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. 

Steps:

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 

http://office.microsoft.com/en-us/sharepoint-server-help/manage-and-share-web-parts-and-web-part-pages-HA010024106.aspx#BM4

Have fun.

Rod

<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>
</DeleteParameters>
</SharePoint:SPDataSource>