XSLT and Alternating Rows

Saw this today (it is over a year old though) on Roger Hartford’s blog;

XSLT alternating rows

In an XSLT template tag you can simulate the same functionality as in  GridView/DataGrid “AlternatingRowClass” property using this syntax:
<div class=”MyClass”>
    <xsl:if test=”position() mod 2 != 1″>
        <xsl:attribute  name=”class”>AnotherClass</xsl:attribute>
It’s that simple!

I’m a big fan of XSLT based processing… and it is great to see ways to get exactly the results you want without additional server or client side code…

Author: Duncan Mackenzie

I'm the Developer Lead for the Channel 9 team, formerly worked on MSDN as a developer, content strategist and author.

Leave a Reply