Making Site Templates with Data Views actually WORK

Following on from my previous post about naming DataSources to use ListName rather than ListID, I thought I would share another secret.

Y'see, you may have noticed that even if you create a re-usable Web Part, you can't just save the whole site as a template and then create new sites ... the Data View web part breaks again.

So what gives? Well, SharePoint in its infinite wisdom, saves Data Library Source information in ListID form. To fix this, you'll need a CAB viewer (such as WinZip or 7-Zip), and a CAB creator (I use the free ZipWrangler tool).

All you need to do is open the .stp file (it's just a renamed CAB file) and extract all the files. Next, open each .000 file and look for ListID attributes. You'll need to work out which ListID maps to which ListName and then replace lines like:

<asp:Parameter Name="ListID" DefaultValue="7866866B-9F9C-4931-92DB-32D5F947BCFF" />

with:

<asp:Parameter Name="ListName" DefaultValue="Keywords" />