Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Did anybody tried Filtering Linked Data Sources using the QueryString as paramters in CAML (Select Command) and not XSLT filters

AggregateDataSource with Parameter

<DataSources><SharePointWebControls:AggregateDataSource runat="server" IsSynchronous="false" SeparateRoot="true" id="New_x0020_Data_x0020_Source1"><sources><SharePointWebControls:spdatasource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;ID&quot;/&gt;&lt;Value Type=&quot;Counter&quot;&gt;{ID}&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;PublishedDate&quot; Ascending=&quot;FALSE&quot;/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;ViewFields&gt;&lt;FieldRef Name=&quot;ContentTypeId&quot;/&gt;&lt;FieldRef Name=&quot;Title&quot;/&gt;&lt;FieldRef Name=&quot;_ModerationComments&quot;/&gt;&lt;FieldRef Name=&quot;File_x0020_Type&quot;/&gt;&lt;FieldRef Name=&quot;Body&quot;/&gt;&lt;FieldRef Name=&quot;NumComments&quot;/&gt;&lt;FieldRef Name=&quot;PostCategory&quot;/&gt;&lt;FieldRef Name=&quot;PublishedDate&quot;/&gt;&lt;FieldRef Name=&quot;_ModerationStatus&quot;/&gt;&lt;FieldRef Name=&quot;ID&quot;/&gt;&lt;FieldRef Name=&quot;ContentType&quot;/&gt;&lt;FieldRef Name=&quot;Modified&quot;/&gt;&lt;FieldRef Name=&quot;Created&quot;/&gt;&lt;FieldRef Name=&quot;Author&quot;/&gt;&lt;FieldRef Name=&quot;Editor&quot;/&gt;&lt;FieldRef Name=&quot;_HasCopyDestinations&quot;/&gt;&lt;FieldRef Name=&quot;_CopySource&quot;/&gt;&lt;FieldRef Name=&quot;_UIVersion&quot;/&gt;&lt;FieldRef Name=&quot;_UIVersionString&quot;/&gt;&lt;FieldRef Name=&quot;Attachments&quot;/&gt;&lt;FieldRef Name=&quot;FileRef&quot;/&gt;&lt;FieldRef Name=&quot;FileDirRef&quot;/&gt;&lt;FieldRef Name=&quot;Created_x0020_Date&quot;/&gt;&lt;FieldRef Name=&quot;FSObjType&quot;/&gt;&lt;FieldRef Name=&quot;FileLeafRef&quot;/&gt;&lt;FieldRef Name=&quot;PermMask&quot;/&gt;&lt;/ViewFields&gt;&lt;/View&gt;"><SelectParameters><asp:Parameter Name="ListID" DefaultValue="5A97A2C9-5609-47DE-A259-9DF3CCD3BB7D"/></SelectParameters><DeleteParameters><asp:Parameter Name="ListID" DefaultValue="5A97A2C9-5609-47DE-A259-9DF3CCD3BB7D"/></DeleteParameters><UpdateParameters><asp:Parameter Name="ListID" DefaultValue="5A97A2C9-5609-47DE-A259-9DF3CCD3BB7D"/></UpdateParameters><InsertParameters><asp:Parameter Name="ListID" DefaultValue="5A97A2C9-5609-47DE-A259-9DF3CCD3BB7D"/></InsertParameters></SharePointWebControls:spdatasource><SharePointWebControls:spdatasource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;_ModerationStatus&quot;/&gt;&lt;Value Type=&quot;Text&quot;&gt;Approved&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;Created&quot; Ascending=&quot;FALSE&quot;/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;ViewFields&gt;&lt;FieldRef Name=&quot;ContentTypeId&quot;/&gt;&lt;FieldRef Name=&quot;Title&quot;/&gt;&lt;FieldRef Name=&quot;_ModerationComments&quot;/&gt;&lt;FieldRef Name=&quot;File_x0020_Type&quot;/&gt;&lt;FieldRef Name=&quot;Body&quot;/&gt;&lt;FieldRef Name=&quot;PostTitle&quot;/&gt;&lt;FieldRef Name=&quot;PostID&quot;/&gt;&lt;FieldRef Name=&quot;_ModerationStatus&quot;/&gt;&lt;FieldRef Name=&quot;ID&quot;/&gt;&lt;FieldRef Name=&quot;ContentType&quot;/&gt;&lt;FieldRef Name=&quot;Modified&quot;/&gt;&lt;FieldRef Name=&quot;Created&quot;/&gt;&lt;FieldRef Name=&quot;Author&quot;/&gt;&lt;FieldRef Name=&quot;Editor&quot;/&gt;&lt;FieldRef Name=&quot;_HasCopyDestinations&quot;/&gt;&lt;FieldRef Name=&quot;_CopySource&quot;/&gt;&lt;FieldRef Name=&quot;_UIVersion&quot;/&gt;&lt;FieldRef Name=&quot;_UIVersionString&quot;/&gt;&lt;FieldRef Name=&quot;Attachments&quot;/&gt;&lt;FieldRef Name=&quot;FileRef&quot;/&gt;&lt;FieldRef Name=&quot;FileDirRef&quot;/&gt;&lt;FieldRef Name=&quot;Created_x0020_Date&quot;/&gt;&lt;FieldRef Name=&quot;FSObjType&quot;/&gt;&lt;FieldRef Name=&quot;FileLeafRef&quot;/&gt;&lt;FieldRef Name=&quot;PermMask&quot;/&gt;&lt;/ViewFields&gt;&lt;/View&gt;"><SelectParameters><asp:Parameter Name="ListID" DefaultValue="C5635ED3-F6B9-48B3-9A79-1C2B5C256701"/></SelectParameters><DeleteParameters><asp:Parameter Name="ListID" DefaultValue="C5635ED3-F6B9-48B3-9A79-1C2B5C256701"/></DeleteParameters><UpdateParameters><asp:Parameter Name="ListID" DefaultValue="C5635ED3-F6B9-48B3-9A79-1C2B5C256701"/></UpdateParameters><InsertParameters><asp:Parameter Name="ListID" DefaultValue="C5635ED3-F6B9-48B3-9A79-1C2B5C256701"/></InsertParameters></SharePointWebControls:spdatasource></sources><aggregate><concat name="data source"><datasource name="Posts" id="0" Type="SPList"/><datasource name="Comments" id="1" Type="SPList"/></concat></aggregate></SharePointWebControls:AggregateDataSource></DataSources>

Parameter Bindings

<ParameterBindings><ParameterBinding Name="dvt_apos" Location="Postback;Connection"/><ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/><ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/><ParameterBinding Name="ID" Location="QueryString(ID)" DefaultValue="1"/></ParameterBindings>
share|improve this question

3 Answers 3

up vote 2 down vote accepted

You can use the values of Query String parameters by setting up parameters in your DVWP and then using those values in your filters. The net effect of this is to alter the CAML to contain the filtering.

Creation of each parameter will create a line in the ParameterBindings section like this:

<ParameterBinding Name="ID" Location="QueryString(ID)" DefaultValue=""/>

You can then use that value in your CAML, something like this:

selectcommand="&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;ID&quot;/&gt;&lt;Value Type=&quot;Counter&quot;&gt;{ID}&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;"
share|improve this answer
    
@Marc : I did used QueryString PArameters in normal DVWP many times, but it doesn't work with LinkedDataSources, Just let me know if it should work then I will invest more time OR I am planning to use SPServices to replicate Linked Datasources :) –  Vamsi Jul 17 '10 at 6:14
    
@Marc : Even a normal paramter like this <ParameterBinding Name="ID" Location="None" DefaultValue="1"/> is not working :( –  Vamsi Jul 17 '10 at 6:22
    
Can you post your AggregateDataSource and ParameterBindings sections? –  Marc D Anderson Jul 17 '10 at 20:09
    
Novice: This does work just as Marc posted. He's personally shown me these and I know it works. Keep plugging away at it. There is a learning curve with XSL, but you eventually will get it. –  iOnline247 Jul 17 '10 at 20:09
    
@Marc : I added the datasource and parameter bindings –  Vamsi Jul 18 '10 at 19:57

@Marc: can I access to CAMLVariable like HttpvDir or HttpPath or HttpHost, if I am creating AggregrateDataSource..?

I am not able to get any of the values for above parameters though I have declare them in ParameterBindings section..

share|improve this answer

I got it working. You need to add DataFormParameter. Please refer to http://spisnotthedevil.blogspot.co.uk/2012/12/dynamic-filter-on-linked-datasource.html for more details.

Eg:

<ParameterBindings>
   . . .
  <ParameterBinding Name=”Department” Location=”QueryString(Dept)” DefaultValue=”Human Resources”/>

      <SelectParamters>

            . . .

. . .

</SharePoint:SPDataSource>

      <SharePoint:SPDataSource . . .   SelectCommand=” . . . ” . . .>

      <SelectParamters>

            . . .

. . .

</SharePoint:SPDataSource>

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.