我想在ASP.net MVC Razor視圖的Sr. No.列內的以下代碼的第一列顯示增量值。我正在做下面的事情,但它不工作。它顯示0 ++;只在該欄中。我在做什麼錯。在asp.net mvc剃刀視圖中增量
@{int i = 0;}
<table class="table">
<tr>
<th>Sr No.</th>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.ModifiedDate)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
<span>@i++;</span>
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.ModifiedDate)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.CurrencyCode }) |
@Html.ActionLink("Details", "Details", new { id = item.CurrencyCode }) |
@Html.ActionLink("Delete", "Delete", new { id = item.CurrencyCode })
</td>
</tr>
}
我++ ;,取出@ – Sherlock
' @(I ++)'(你需要周邊括號) –
' @i 我++;' –