SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 1 down vote accepted

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 :)

share|improve this answer
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. – JᴀʏMᴇᴇ Apr 29 '13 at 9:49
@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. – Daniel Ziga Apr 29 '13 at 10:40
Given the fact we need to keep these files separately, I've implemented your first solution. Thanks again mate, appreciate it. – JᴀʏMᴇᴇ Apr 29 '13 at 11:18

Your Answer


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.