Monday, June 3, 2013

TIP: How to Change a DVWP field to Configurable QueryString Hyperlink

Introduction

If you're building dynamic pages employing query-strings methods, you may want to employ the Data View Web Part (DVWP) to generate a list of query string hyperlinks in order to build master-detail pages and other custom dashboards.  The problem is, the DVWP doesn't present fields as hyperlinks OOTB and the hyperlink options are limited.  Additionally, the DVWP doesn't identify individual fields in the XML markup that you can modify.  However, using SharePoint Designer 2010, you can make Designer expose the XML to the fields you want to modify as hyperlinks. The following procedure shows you how.

This procedure assumes that you already have an ASPX page that you want to modify and that you have already dropped on DVWP onto this page and connected it to a list.

Procedure

1) In the DVWP, select the field that you want to turn into a query string hyperlink. 

Selecting the field causes a Tasks link to appear next to the field: Common xsl:value-of Tasks.  Alternatively, you can right-click the selected field, which opens a popup menu.

2) From the Tasks menu, choose Show Link to Item.  This changes the field into a hyperlink that points to a form. 

Don't worry about the extra XML: you can remove it.  More importantly, this action causes SharePoint Designer to modify the underlying XMLso that the appropriate XMLfield is exposed so that you can edit it.

3) Review the code and look for the fieldname associated with the field you selected.  You should find something like:
$thisNode/ @ FieldName
(NOTE: there are no spaces before and after the "@".  These spaces were added to prevent this HTML editor from automatically configuring this as an email address.)
Remove the XML that points to a new form.  This line is now ready for you to modify as needed in order to implement it as a query string.

Summary

In this posting, you have explored how to use SharePoint Designer 2010 to expose the XML associated with a specific DVWP field so that you can modify this field XML as a hyperlink.

Further Reading

No comments: