Tuesday, April 30, 2013

Using webpart in masterpage generates error on subsites

Using a dataview webpart in a masterpage created the following error on subsequent subsites:
“Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator.”
Reason:  Subsite doesn't have that list specified on the webpart and doesn't know to look at the root.

Resolution: Add the following parameter (in green) in the <SelectParameters> section:

   <SelectParameters>
        <asp:Parameter Name="ListName" DefaultValue="Tasks" />
        <asp:Parameter Name="WebID" DefaultValue="RootWeb" />    </SelectParameters>