Using C#, I am inserting web parts into web part zones programmatically and styling them. More specifically, I'm inserting CQWP's and assigning XSLT files to them.

I'm now wanting to allow users to insert their own CQWP's into the web part zone's through the UI and make available the same styles.

I can obviously insert the CQWP into the zone, but under Item Styles I don't see the same templates as what are defined in my XSLT file, which I can see for the CQWP's that were inserted programmatically.

Why are none of the XSLT templates available to me under the available styles for these CQWP's?

1 Answer 1


If you insert the default CQWP throught the UI it will automatically use the ItemStyle.xsl from the Style Library by default.

In order to do what you want to do, you'd have to create your own CQWP and add some EditorPart or Toolpart to it in which you include the functionality to be able to choose whatever XSLT file for itemstyles you want.

Here's an example on how to extend the CQWP (aka. create your own).

Here's an example on how to add your own EditorPart/ToolPart to the webpart.

Hope it helps :)

  • Thanks a lot Daniel, appreciate your answer. I'm disappointed this is the only way to achieve this but I'll begin reading up on extending the CQWP nevertheless. Thanks again. Apr 29, 2013 at 9:49
  • 1
    @DeeMac It's either this solution or you're going to have to add your custom itemstyles in the ItemStyle.xsl file in Style Library. That way you don't have to create your own XSL files and include them seperately.
    – user2536
    Apr 29, 2013 at 10:40
  • Given the fact we need to keep these files separately, I've implemented your first solution. Thanks again mate, appreciate it. Apr 29, 2013 at 11:18

Your Answer

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

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