SharePoint – Pass a Parameter as FILTER value to a Web Part

January 22, 2015

Click on the relevant Web Part -> Right Side -> Click on Hyperlink

Keep in mind EACH WebPart has a separate Data Source Field, Filter and Sort Settings !



First Create a New Parameter value based on a Query String Variable.


Next set the DVWP Filter settings


The result is that the data in DVWP will be filtered on load, by the Query String variable.

Second Example is to Filter a DVWP based on a Field value.

Based on the Query String Parameter you can filter the detail list web part for the items added.


It will look like this. There is some garbage appearing on top of the DVWP ?


Solution :

Just open the Form again in SP Designer and comment out that section to get rid of it.

    <td width="25%" class="ms-vb">
    <b>File Type:</b>
 <xsl:value-of select="@HTML_x0020_File_x0020_Type.File_x0020_Type.mapico"/>


Look in the code for <!—…. –>

Filtering is quite handy !

SharePoint – Query String Parameters

January 22, 2015

In your development project you might need at some point in time to create a Query String Parameter.

But there are some challenges if you want to pass this to a Form Variable !

Here we go :

1. Create a Query String Parameter any string is fine.  and construct your URL.

2. Create a JQuery function for the receiving party.

$(document).ready(function() {

var lastId = $().SPServices.SPGetLastItemId({
    listName: "Sample_Header"});

var nextId = Number(lastId) + 1;
 //alert("Last ID " + lastId);

    $("#Details").click( function()
                      alert("Next ID " + nextId );
     var URL = '/sites/Lists/Sample/NewForm.aspx?HeaderID=' + nextId ;
     alert ('We go to this ' + URL);
    window.location.href = URL;

In this case we will use the parameter to filter a Data View Web Part. So add the script in the receiving Form to intercept is and pass it on to a Data View Parameter

3. Create the DVWP Parameter

In SharePoint Designer create a new Parameter


We call it as well HeaderID and refer to the Query String Parameter called HeaderID.



This does NOT work for a Item Display Form a DVWP ?

Solution is to add this in the standard DISPLAY form NOT as a CUSTOM FORM.


But as a Display Item Form from the menu.


Don’t ask me why ?

For the other Forms (Edit and New) it does not seem to be a problem.

Best always test both ways in case of problems, anyhow.

In case you need to do some manual changes to the Forms.

Don’t use the Insert NEW Item Form from the MENU. Otherwise it goes wrong ?

Choose CUSTOM LIST FORM instead.


Choose for the list you need.


So bottom line is that it is not so straight forward, to get the ball rolling Sad smile