none
Parameters not being read by CAML query in Dataview

    Question

  • What I am attempting to do is select the files in a folder which is defined by the querystring. The CAML query works if I remove the parameter reference and enter a value. For some reason it is acting like that parameter reference isn't there. I'm unsure as to what the solution is.

    I'm not locked into getting at the content I want this way. If you can offer a fix for my code or and alternate method I would appreciate it.

    <DataSources>
    	<SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;And&gt;&lt;Eq&gt;&lt;FieldRef Name='FileDirRef'/&gt;&lt;Value Type='Choice'&gt;{RootFolder}&lt;/Value&gt;&lt;/Eq&gt;&lt;Eq&gt;&lt;FieldRef Name='ContentType'/&gt;&lt;Value Type='Text'&gt;Picture&lt;/Value&gt;&lt;/Eq&gt;&lt;/And&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;ViewFields&gt;&lt;FieldRef Name='FileRef'/&gt;&lt;FieldRef Name='FileDirRef'/&gt;&lt;FieldRef Name='LinkFilenameNoMenu'/&gt;&lt;FieldRef Name='Title'/&gt;&lt;/ViewFields&gt;&lt;/View&gt;" Scope="RecursiveAll" id="dataformwebpart3">
    		<DeleteParameters>
    			<WebPartPages:dataformparameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{77E8650C-19CB-404A-92F9-FDDBD8C1E560}" Name="ListID"></WebPartPages:dataformparameter>
    		</DeleteParameters>
    		<InsertParameters>
    			<WebPartPages:dataformparameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{77E8650C-19CB-404A-92F9-FDDBD8C1E560}" Name="ListID"></WebPartPages:dataformparameter>
    		</InsertParameters>
    		<SelectParameters>
    			<WebPartPages:dataformparameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{77E8650C-19CB-404A-92F9-FDDBD8C1E560}" Name="ListID"></WebPartPages:dataformparameter>
    			<WebPartPages:dataformparameter ParameterKey="RootFolder" PropertyName="ParameterValues" DefaultValue="thd/Images1" Name="RootFolder" />
    		</SelectParameters>
    		<UpdateParameters>
    					<WebPartPages:dataformparameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{77E8650C-19CB-404A-92F9-FDDBD8C1E560}" Name="ListID"></WebPartPages:dataformparameter>
    		</UpdateParameters>
    	</SharePoint:SPDataSource>
    </DataSources>
    					
    <ParameterBindings>
    	<ParameterBinding Name="RootFolder" Location="QueryString(RootFolder)" DefaultValue="thd/Images1"/>
    </ParameterBindings>
    
    Thursday, December 10, 2009 5:15 PM

Answers

All replies

  • I would suggest you give up this approach, since there's no documentation on the declarative elements of SharePoint DV parameter.

    You should try using SPGridView(http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spgridview.aspx) to use your own CAML query.

    Displaying Data by Using the SPGridView Control in Windows SharePoint Services 3.0(http://msdn.microsoft.com/en-us/library/bb466219.aspx)

    Cogito ergo sum.
    • Marked as answer by Chengyi Wu Friday, December 18, 2009 2:09 AM
    Wednesday, December 16, 2009 2:31 AM
  • Alawain

    You can check this http://blogs.msdn.com/sharepointdesigner/archive/2007/04/24/spdatasource-and-rollups-with-the-data-view.aspx

    till that time i'm also trying to get it working
    Thanks
    SpidyNet
    • Marked as answer by Chengyi Wu Friday, December 18, 2009 2:09 AM
    Wednesday, December 16, 2009 4:04 AM
  • Hi,

    Running into the same problem...has anyone resolved this?

    I'm guessing it's because @Path (CAML FileDirRef) does not have a leaading slash and RootFolder does.  As Alawain reports if we enter the text of the root folder minus the leading slash the filter works.  Re-enter the paramter and it returns nothing.

    The crux of the problem is here:&gt;&lt;FieldRef Name='FileDirRef'/&gt;&lt;Value Type='Choice'&gt;{RootFolder}&lt

    FileDirRef is of the form site/lists/listname/foldername

    RootFolder is of the form /site/lists/listname/foldername so they are not equal.

    Unfortunately I'm not aware of a means of calculating (removing the leading slash) from the RootFolder paramter, or conversely Adding it to the CAML FileDirRef...does anyone else?

    I read through the SPGridView links...unfortunately I'm in sharepoint designer at the moment...if I could only get this last part done it would work.  I sort of hate to custom code this just for a silly slash :(

    I guess a "contains" rather than equals in the CAML would work...is there one of those?

    Best regards,

    S'

    Thursday, July 22, 2010 7:48 PM
  • WooHoo!

    Tried a couple of things...there is a CAML contains, but that didn't seem to work.  Tried reversing the fields, still nada.

    In SPD tho, opened the filter, took out other filters, then checked XSLT Filter and entered [contains(MyRootFolderParameter,@Path)].

    This translated to a blank <SharePoint:SPDataSource select command, and added it later in the dvt_1 template as

    <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[contains($ThisRootFolder,@FileDirRef)]"/>

    Much nicer!!!!

    Best regards,

    S'

    Thursday, July 22, 2010 8:27 PM