Sunday, November 14, 2004

Data View Web Parts

Although in my last post I mentioned SharePoint from the project management perpective, here's a tip that's purely development.

One thing that winds me up is how SharePoint deals with ghosted pages. As soon as a page is unghosted it's lost to any future template changes. If you unsure to what unghosted pages are in SharePoint let me assure you they are "a bad thing".

Now should you wish to create a data view web part from an existing list, you have to do it in FrontPage, and you have to then hit the save button, unghosting it and casting the page down in to the 7th circle of SharePoint annoyances.

Unless...

You first create a new web part page, and place your list as a web part on that new page. Then in FrontPage convert it into a Data View web part and do all the customisations you wish. Once done, hit save.

Then visit the page in Internet Explorer. Modify the properties of the data view web part and you'll see the three buttons in the toolpane that displays the properties on the data view web part (Source Editor, DataQuery Editor, Parameters Editor). Open each property window and copy and paste the values to 3 local text files.

You can now delete the web part page and the data view web part it contains. (Although I'd recommend waiting until you know this whole process has worked)

Now go to the page you really want to display the data view web part on.

Drop an empty Data View web part in to a zone. Open the toolpane, and for each property button paste in the values from your local text files.

You'll now have your customised Data View web part, and no unghosting will have taken place!

High-five!

What’s that? You don't have an empty Data View web Part? Ah.

Right-click save target as on http://gilesgregg.com/Data%20View%20Web%20Part.dwp.

Copy it in to your wpcatalog folder under the sites’ root iis folder and you'll then find it under the Virtual Server gallery.

Alternativly you could export the web part to a .dwp file off the temporary web part page and then import it to the destination page. This is certainly an easier method in the short term, but I've found having an empty data view web part in the Virtual Server gallery quite useful.

Any feedback gratefully received...

3 Comments:

Anonymous Anonymous said...

Why don't you just export the webpart from the un-ghosted page, and then import it into the new ghosted page? That will save time and effort having to manage three separat property strings...

2:51 pm  
Blogger Giles Gregg said...

I mentioned that export/import option at the end of my article, and it certainly is easier. However, I think learning exactly how the Data View web part works is a useful exercise.

5:08 pm  
Anonymous Anonymous said...

Hi,
I added the data view web part to the page, however i got an error "the list does not exist..."
Is there away to solve it?
10x
ariel

11:13 am  

Post a Comment

<< Home