Click here to Skip to main content
Click here to Skip to main content

How to Customize SharePoint List Content Display using Content Query Web Part

By , 21 Dec 2011
Rate this:
Please Sign up or sign in to vote.

Here I'm going to describe how we can use Content Query Web Part to Style SharePoint List. Thus Assume we are having a  SharePoint List Called Projects with Following Fields.


As you already knew default look and feel would be like below.


Now I'm going to render this list in to format something like below.


Step One

First you need to define Some names for these place holders (Yeh., I know this do not make any sense to you. But don’t worry just do the step). Thus I'm going to define these columns as follows.

  • Title –> MyTitle
  • Logo –> MyLogo
  • Project Summary –> MySummary
  • Project Description –> MyDesc

Step Two

Now you want to define a XSL Style Sheet using these names. Therefore I'm going to use <table> to layout the list item as below.

<xsl:template name="MyStyle" match="Row[@Style='MyStyle']" mode="itemstyle">

<table border='1'>
        <td colspan="2"><h3><xsl:value-of select="@MyTitle" /></h3></td>
            <xsl:attribute name="src">
                <xsl:value-of select="@MyLogo" />
            <xsl:value-of disable-output-escaping="yes" select="@MySummary" />
        <td colspan="2">
            <xsl:value-of disable-output-escaping="yes" select="@MyDesc" />

here i used XSLT to position the content inside my html tags. There are few attributes which are mandatory in this section. 

  • Name and Match should have equal names.
    • name =’X’ match=Row[@style=’X’]
  • mode = ‘itemstyle

now you have created XSLT which can given as a list style in the SharePoint.

Step Three

here we are going to put XSLT to the SharePoint.

First you need to open the SharePoint designer with the particular site. Then navigate to All Files and Style Library.

Here you can see many Folders inside. Now you have to go to XSL Style Sheet Folder.

Now you can see XSL files which are used by SharePoint to render it’s content. Here we are using ItemStyle.xsl for enable custom rendering.


Thus open this xsl file and put your xsl (when we created in step two) in the bottom of the xsl as follows.

Now difficult things are over.

Step Four

  • Add a Content Query Web Part
  • then go to edit web part and  and browse your list. ( here our list is Our Projects )
  • Then go to presentation section. and go little bit down. You can see style drop down.
  • Wow ..  Now you can see your style.
  • Ok the then select your custom xsl ( here MySample).
  • When you select you can see something like below.
  • Now you need to put actual list column names to these text boxes as follows.(Title column should use with the scope)
  • Then Click ok to Save. Now Every thing ok. You can see your new list rendering now.

Happy SharePoint Smile | :)


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author


Sri Lanka Sri Lanka
No Biography provided

Comments and Discussions

QuestionThanks for your article. PinmemberDoan Quynh26-Sep-13 15:28 
GeneralCustomize SharePoint Lists, Add Barcode Fields Inside SharePoint List PinmemberUsman Sarfraz4-Jun-12 22:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140421.2 | Last Updated 21 Dec 2011
Article Copyright 2011 by Melick
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid