Challenge:
You’re working with SharePoint Designer 2010, and trying to add Data Form Web Part to your Page Layout. There are numerous articles explaining how you should change ListID to ListName and everything should be fine.
Well, the DFWP road might sometimes be long, so here are few things I noticed that might save you a few moments especially when trying to make reusable DFWP that would reference to a list always on the site on which the Web Part is sitting in.
Solution:
- You must remove attributes related to WebURL if you want to make reusable DFWP
- Remove WebURL from WebPartPages:DataFormWebPart > ParameterBinding
and
SharePointWebControls:SPDataSource > (Select/Delete/Insert/Modify)Parameters > WebPartPages:DataFormParameter
- You can remove SharePointWebControls:SPDataSource > (Delete/Insert/Modify)Parameters if you only use Web Part for showing items
- For reusable DFWP you must remove WebPartPages:DataFormWebPart’s attributes called listname and ListID.
- For reusable DFWP you must replace ParameterBindings and xsl:params ListID with ListName
- Also remember to change the GUID to list name
- If your list name contains space character, it’s OK, you can have space character in ListName attribute
- NOTE! SharePoint Designer keeps adding some attributes to DFWP even if you don’t use Save. It’s enough if you just close the file and reopen it, the ListName and ListID attributes with GUID values can suddenly be in WebPartPages:DataFormWebPart node.
- If it still doesn’t work, remove id and __WebPartId attributes form the WebPartPages:DataFormWebPart tag and let SPD generate them again.
- Always keep notepad open and copy paste your working code there
- Before copying the working markup to notepad, make sure SPD hasn’t injected ListName and ListID GUID attributes from WebPartPages:DataFormWebPart node
- Do not do this:
- Edit Page Layout file in SPD window
- Save file
- Close the Page Layout file window in SPD <<<---- No, no, no!
- Check in file in SPD
--> SPD will insert ListName and ListID attributes into your DFWPs
- Do this instead:
- Edit Page Layout in SPD window
- Save file
- In another SPD window in folder view check in your Page Layout file
- Close the Page Layout file window
Finally, if you're getting the "List does not exist" error and you're code is exactly how it should be, copy the last working version of DFWP from your backup file. If you compare the working and non-working DFWP's you won't probably notice any differences; at least I didn't; so it might be enough just to cut&paste the same DFWP code back.
Technorati Tags:
SharePoint