DataView webpart - Formatting alternating rows
I like to format everything in a data view webpart. It is tricky to get the alternating rows formatting to work correctly. Here is an example that is working:
You must remove the <xsl:variable name="dvt_StyleName">[stylename]<xsl:variable> tag so that we can assign a class to the table and style it our way. For some reason the xsl style does not work as expected.
Note: the entire page is styled with a dark background, #212121, so this is why I style the table with a white background.
Add the DVTable to the table just before the headings <th> tags. I actually replace the <th> tags with my own <td> tags and style the cell for a good background and the span tag for text effects.
Now we need to replace the style that is applied when the <xsl:if test="position() mod 2 = 1"> is run (this tests to see if the row is an odd row and then applies a style to it. (I tried to replace this xsl:if with an xsl:choose and xsl:when for condition odd and even, applying separate styles to each, but it would not apply the style to the xsl:otherwise condition.
<xsl:if test="position() mod 2 = 1">