Saturday, 24 August 2013

Dynamic Table alternate background - MVC3

Dynamic Table alternate background - MVC3

I have two tables in my view; trying to change the background of alternate
rows in one table. in my style file I am using:
.alternateRow
{
table-layout: auto;
border-collapse: collapse;
border-spacing: 0px;
empty-cells: hide;
}
.alternateRow tr {
background-color:#aa0000;
}
.alternateRow tr.odd {
background-color:#00AA00;
}
This is how I make the dynamic table:
<table class="alternateRow">
<% List<Question> wrongs = ViewBag.wrongs;
for (var i = 0; i < wrongs.Count; ++i)
{ %>
<tr>
<td>
<%= wrongs[i].TheQuestion %>
</td>
<td>
Correct Answer
</td>
<td>
<%= wrongs[i].CorrectAnswer %>
</td>
<td>
<%= wrongs[i].Explanations %>
</td>
</tr>
<% } %>
I did not work, both rows have the same color. Any idea what I am doing
wrong, thanks in advance.

No comments:

Post a Comment