Search This Blog

Tuesday, March 1, 2011

How to show the query string as a title of a list view/Data view web part in SharePoint 2010 using XSLT


Requirement

We needed the title of the xslt list view web part displayed as View "Query string value" documents or View "Query string value" announcements etc

Solution

We considered the following ways to display the title:

  • Using Javascript
  • customizing the XSLT of the list view web part


The second method was followed.

To display the title as the query string in the XSLT list view web part use the following steps:

Click here to learn basics of XSLT.
  1. Edit the page in advanced mode in SharePoint designer (Note: Detach the page from the page layout if you are using a publishing page layout).
  2. Insert the list view web part
    1. Move the cursor over the web part zone in markup or design view. 
    2. From the ribbon's insert tab insert the list using the data view button.
  3. Highlight/Select the list/data view web part in design view.Customize the XSLT of the list view web part from the design tab's Customize XSLT ->Customize entire view option.
  4. With the list/Data view web part highlighted, select the options tab and click on the parameters button.
  5. Create a new parameter with the parameter source as the query string and set the query string variable name to "your query string's variable" name.
  6. Insert the following lines of xslt code, just before the <table> tag to display the query string as a title to the list view web part.
  7. <h2><xsl:value-of select="$ParameterName"/> documents etc</h2>
  8.  Save (and publish) the page.

No comments:

Post a Comment