Chapter 5. Hyperlinks in the Data View Web Part

In SharePoint, List and Library views are used to look at the same set of data in different ways. When views are created, columns, filters, sorting, and grouping are set up in an easy user interface. There are some additional settings such as totals, inline editing, and styles, but in a lot of cases, there is a point at which the out-of-box settings are not sufficient for the goals of the business.

When the settings do not provide the needed customization for the List or Library view requirements, you can use SharePoint Designer to create a Data View web part (DVWP) or an XSLT List View web part. There is a plethora of view modifications that you can make. The following are the most common reasons for customizing List views:

In this chapter, you will learn that there is a difference between Data View and XSLT List View web parts, and how hyperlinks are customized in each. The hyperlinks will also be structured differently for libraries than they are for lists. Therefore, an overview of SharePoint URL structures will be provided.

In May 2009, I originally wrote an article with an associated screencast, called “Data View Web Part, The Basics—Add a Hyperlink.” It has had many site visits over the years, and is my most popular EndUserSharePoint (EUSP) article.

I wrote this article before SharePoint 2010 was released. Back in SharePoint 2007, there was only one way to modify a List view with SharePoint Designer, and that was to create a DVWP. My article is very simple. It includes eight steps for a document library and six steps for a list. This chapter is based on that original article, but there is much more to it. When SharePoint 2010 was released, it introduced the concept of XSLT List View web parts. This means that any List or Library view can be edited directly in SharePoint Designer, and can also still be edited in the browser’s view settings, even after the view has been edited using SharePoint Designer. Instead of having two simple sets of instructions for a list DVWP and a library DVWP, this chapter has four sets of instructions. Now there is an additional set of steps for a library XSLT List View web part, and different steps for a list’s XSLT List View web part.

Some lists and libraries will be needed for the test environment for the step-by-step instructions in this chapter. Here is a high-level overview of the content that will be used:

Notice that the temporary ASPX pages are created as a test location for the creation and modification of DVWPs. This is not done for XSLT List View web parts. With a DVWP, the idea is that it is created in a temporary location and then exported from there and finally imported cleanly onto the site home page or wherever it needs to be displayed. Unfortunately, this same functionality just doesn’t quite work with XSLT List View web parts. When an XSLT List View web part is created in a temporary location, exported, and then imported onto another page, at first it looks just fine. As soon as you exit Edit mode on the page, however, all of your formatting changes are lost and it reverts back to the default view of the list. You’ll notice that with the XSLT List View web parts, we create a new view, but we do not bother with a temporary location on a web part page.

In this walkthrough, the test site and the example list and library will be created. Since lists and libraries have different URL structures, each one will be demonstrated.