How to query a list by name using the SharePoint DataView Web Part?

1.1k views Asked by At

I have multiple DataView Web Parts that are getting items from a list in SharePoint 2010. The web parts are in a subweb and the data from the list is in the root web. I can get this web part to work just fine by specifying the ID of the list:

<dsp:dsQuery select="/list[@id='GUID GOES HERE']" resultContent="Both" resultRoot="Rows" resultRow="Row" columnMapping="Attribute">

However! I cannot use this method of selecting the list by the ID because I will be using export-spweb/import-spweb and moving the subwebs to a different location (this command re-assigns IDs... so after the export/import my web parts break). What I want to do is select the list by something more definite... like below (which does not work):

<dsp:dsQuery select="/list[@name='LIST NAME GOES HERE']" resultContent="Both" resultRoot="Rows" resultRow="Row" columnMapping="Attribute">

To summarize, I need my dataview web parts to use a dsQuery that goes by list name and not ID. Has anyone done this before or am I stuck with editing hundreds of web parts' IDs? That would be awful =)

Any help is appreciated!

1

There are 1 answers

1
Mark On

You can do that by changing List GUIDs to List name. Here is an example: http://salaudeen.blogspot.com/2012/02/how-to-make-dataview-portable.html