k blog.kenaro.com
← All articles

How to deploy conditional formatting in a SharePoint 2010 list definition using Visual Studio 2010

· Ingo Karstein

This time it’s not a walkthrough. Only a description of what you have to do. – It’s “experimental”!!!

The need is to deploy a conditional formatting in a list definition that was created in a SharePoint 2010 Visual Studio (2010) project.

1. You need to design the list definition. Create a list instance for the list definition. This instance you can remove later if you want.

2. Deploy the project. It’s without conditional formatting at this point.

3. Create the conditional formatting in SharePoint Designer.

Open the list instance.

Open the list view you want to modify.

Select the cells that should have a conditional formatting.

Create the conditional formatting.

4. Open the “Code” view of the list view page.

5. Look for the “” tag of the XsltListViewWebPart that renders the list data.

Copy the content of the tag.

6. In Visual Studio open the “Schema.xml” file of the list definition.

7. In the tag look for the view you want to modify. E.g. “AllItems.aspx”. Look for the “Url” attribute of the view tag that contains the Web Part Page name (e.g. “AllItems.aspx”).

8. Before the closing “view” tag add this:

        <Xsl>
              <![CDATA[
              ...
              ]]>
        </Xsl>

Replace the “…” through the copied content of the web part pages “xsl” tag content.

9. Deploy the project.

10. It’s done! – BUT: You may be unable to edit the conditional formatting in SharePoint Designer! As I said: It’s experimental.

2 comments

Karsten Pohnke Mar 16, 2012
Hi, that is a great post which worked for me fine. Thank you for sharing your thoughts. I created a small step by step how to http://www.ilikesharepoint.de/2012/03/sharepoint-2010-conditional-formatting-for-lists-using-visual-studio/ Regards Karsten
ikarstein Mar 26, 2012
Hi Karsten! - Thank you for your comment and for the validation of the nessessary steps...! kind regards, ingo

Leave a comment

Your comment is reviewed before it appears. Your name is shown with the comment; your email is required for moderation but never published.