私は剃刀を使用してHTMLテーブルを出力しようとしています。テーブル自体は動作しますが、今私は、テーブル内の他のすべての行に「偶数」と呼ばれるクラスを追加しようとしています:ASP.NET MVC Razor - 内部の場合
<table>
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
</thead>
<tbody>
@for (int i = 0; i < ViewBag.MyList.Count; i++)
{
var myObject = ViewBag.MyList[i];
<tr @if (i % 2 == 0) { class="even" }>
<td>myObject.Column1</td>
<td>myObject.Column2</td>
<td>myObject.Column3</td>
</tr>
}
</tbody>
</table>
ありループ内その場合、ケースと間違って何かが明らかだが、何がありますこれを書いている正しい方法?
ありがとうdknaack、うまくいきます!そして、にリンクしてくれてありがとう。 :) – haagel