Reputation: 359
Within my DataFormWebPart I have a 'DataSourcesString' property which references and queries a list.
Depending on what page the DataFormWebPart is displayed on I need to be able to configure the query (parameterise the string 'Dispute Resolution' in the code below) within the 'DataSourcesString'.
Does anyone know if there a way to paramterise this by modifying the web part through either the XSL Editor or Paramter Editor?
The web part code snippet relating to the 'DataSourcesString' is below
<property name="DataSourcesString" type="string"><%@ Register TagPrefix="sharepoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><sharepoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand="&lt;View&gt;&lt;Query&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;ID&quot;/&gt;&lt;/OrderBy&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;Primary&quot;/&gt;&lt;Value Type=&quot;Text&quot;&gt;Dispute Resolution&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;" UseInternalName="True" IncludeHidden="True" ID="datasource1">
Thanks! I appreciate this may not be so clear without screenshots..
Upvotes: 0
Views: 1562
Reputation: 3282
You can do this using a QueryString parameter on the DataForm. I'm assuming you're only able to export the webpart. So, export the webpart and save the .webpart to your desktop. Open it and modify it like so:
In your DataSourcesString remove the where clause entirely:
<property name="DataSourcesString" type="string"><%@ Register TagPrefix="sharepoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><sharepoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand="&lt;View&gt;&lt;Query&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;ID&quot;/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;/View&gt;" UseInternalName="True" IncludeHidden="True" ID="datasource1">
In the <property name="ParameterBindings" type="string">
node, add:
<ParameterBinding Name="MyVariable" Location="QueryString(MyVar)"/>
In the XSL for the webpart itself, find <xsl:param name="dvt_partguid" />
and just below it add:
<xsl:param name="MyVar" />
Finally, find select="/dsQueryResponse/Rows/Row
and modify it to be:
select="/dsQueryResponse/Rows/Row[@Primary='$MyVar']
Save the webpart, upload it back, and you should now be able to filter it by adding MyVar=Whatever to your querystring
Upvotes: 1
Reputation: 506
The only way I found of manipulating parameters at run time was from C# code behind.
Here are the steps required:
Upvotes: 0