It’s the first time i got a chance to work on the so called, Swiss knife of SharePoint "Dataform" webpart .
I have a requirement to pull the data (different sitecollection) using dataform webpart
and filter the data based on the field value of the page(created based on page layout) where the webpart is placed on.
As it is cross site querying, I have to add a new
SOAP datasource and configure it to dataform webpart. I could pull the data,
so how to access the page field value inside the dataform webpart xsl?
ParameterBinding is the solution for it.
It allows you to declare the external parameters that can be accessed by dataform webpart.
So how do we get this work??
Create datasource :
There are many feeds lying out there on web that would help you to create a soap datasource and pull data using dataform webpart with the help of Sharepoint Designer.
Define ID attribute:
Make sure ID attributes are set for the page fields that you want to access in dataform webpart. For example i want to access a look up field that is part of a pagelayout which is defined as
In Sharepoint designer 2010 click on the dataform webpart to see the its properties/settings
on the ribbon. Click on parameters on options tab as shown below
Name the parameter "lookupFieldParam" that should be binded to the pagefield control
holding the id PageFieldSrc as selected in the screen. Default value for this new param can also be selected.
After you click on ok, designer adds the necessary param definition xsl tags to the dataform webpart. The place you should care about to have it is under
<ParameterBinding Name="lookupFieldParam" Location="Control(PageFieldSrc,ItemFieldValue)" DefaultValue="ABC" />
Now it’s time to test our efforts...
Add the below xsl tag under row template and create a page based on that pagelayout to see if the parameter is fetching the value.
<xsl:value-of select="$lookupFieldParam" />
Note $ reference here.
So now we have page field value in dataform webpart, how to use this to filter the data in dataform webpart will be drafted in my next version of this post.