For whatever reason, Microsoft in its infinite wisdom seems to have removed the ‘Connect to another library…’ link in the Data Source Library in SharePoint Designer 2010. Maybe that capability is hidden somewhere else now, but as my pal Chris Givens pointed out the other day in his Missing Features from SharePoint Designer 2010 post, it’s not “findable”.
Fortunately there’s a workaround and all of your 2007 Data View Web Parts (DVWPs) should work in 2010. (At least if this is the only issue!) You can simply add the same line into the DataSource that you would get if you used the ‘Connect to another library…’ link in 2007. The net-net in 2007 is that you end up with the WebPartPages:DataFormParameter named WebURL in your DataSource section. That’s the entire difference in the code if you want to access content in a different site: the WebURL parameter. By setting that parameter to the relative URL of the site where the content resides, you can access content in any other site with a DVWP, just like in 2007. You just have to do it manually in the Code View.
Here’s an example of accessing an Announcements list from the root site in a SharePoint 2010 Site Collection which resides in a subsite called ‘Marc’. Note that I’ve also switched from ListID to ListName in this example. As long as your information architecture is solid, that switch can be useful to make your DVWP code more readable. It also can make your DVWP more portable to other sites or Site Collections.
<DataSources> <SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" UseServerDataFormat="true" selectcommand="<View&gt;</View>" id="dataformwebpart1"> <SelectParameters> <WebPartPages:DataFormParameter Name="ListName" ParameterKey="ListName" PropertyName="ParameterValues" DefaultValue="Announcements"/> <WebPartPages:DataFormParameter Name="WebURL" ParameterKey="WebURL" PropertyName="ParameterValues" DefaultValue="/Marc"/> </SelectParameters> </SharePoint:SPDataSource> </DataSources>
Note that you may also need to remove several attributes in the WebPartPages:DataFormWebPart header. If you are getting an error, check for attributes like this:
and remove them. Removing these attributes won’t break the DVWP, and will fix the error.
If you found this post helpful, please consider visiting one or more of the advertisers on the page. Writing good, in depth blog posts takes time, and advertising revenue - though by no means large - helps to offset the effort.