0

I need to generate a dynamic CAML query for DataView web part. My requirement is similar to what is mentioned at: https://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?

1 Answer 1

1

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.

4
  • Can I set value of parameterbinding using JS code / connected webpart? Commented Nov 3, 2011 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. Commented Nov 3, 2011 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? Commented Nov 4, 2011 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. Commented Nov 4, 2011 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.