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

I need to generate a dynamic CAML query for DataView web part. My requirement is similar to what is mentioned at: http://stackoverflow.com/questions/1985560/sharepoint-dynamic-caml-query-problem .

I'm trying to use following Query:

<Query>
    <Where>
        <In>
            <FieldRef Name="ID"/>
            <Values>
                <xsl:for-each select="tokenize($IDs, ',')">
                    <Value Type="Text"><xsl:value-of select="."/></Value>
                </xsl:for-each>
            </Values>
        </In>
    </Where>
</Query>

But I'm not able to use xsl:for-each in CAML query. What could be wrong?

share|improve this question
add comment

1 Answer

XSLT code can be used only inside <Xsl> tag of DVWP. <Query> tag can include only CAML elements described in following MSDN article:

There is no way to create a dynamic CAML query using xslt. You can create it either programmatically (from other webpart on same page or by creating a DataViewWebPart descendant), or you can use parameters (from <ParametersBindings>, like this: {nameOfParameter}) - but the latter approach is rather limited and I'm afraid it couldn't be used in your particular situation, because there is no way to split a parameter into pieces using CAML.

share|improve this answer
    
Can I set value of parameterbinding using JS code / connected webpart? –  Vivek Athalye Nov 3 '11 at 10:40
    
Connected webpart - yes. Also ParameterBindings can be automatically gathered from server controls, form inputs, query string, etc. - depending of Location attribute. But you will be able to use the parameter value only in a limited way, due to CAML query schema limitedness. –  Andrey Markeev Nov 3 '11 at 11:02
    
Thanks for your reply. I'll check how to connect a custom web part with DataView web part. If you have any reference related to this can you please share? –  Vivek Athalye Nov 4 '11 at 4:54
    
I don't, but I anticipate you will need to use SPLimitedWebPartManager to find the DVWP on the page where your custom webpart is placed. –  Andrey Markeev Nov 4 '11 at 10:23
add comment

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.