In MVC3, how do you create alternating row colors on a @foreach list when using the Razor view engine?
@foreach (var item in Model) {
<tr>
<td>@item.DisplayName</td>
<td>@item.Currency</td>
<td>@String.Format("{0:dd/MM/yyyy}", item.CreatedOn)</td>
<td>@String.Format("{0:g}", item.CreatedBy)</td>
<td>@Html.ActionLink("Edit", "Edit", new { id = item.Id })</td>
</tr>
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…