我有以下代碼:試圖用剃刀使用索引來循環
@{
var index=0;
}
@foreach (AdminSummary adminSummary in @Model.AdminSummaries) {
index++;
<div class="rep_tr0">
<div class="rep_td0">@adminSummary.RowKey</div>
<div class="rep_td0"><a href="/Administration/Products/Edit?&[email protected]&[email protected]&[email protected]&[email protected]">Edit</a></div>
<div class="rep_td0"><a href="/Administration/Products/Delete?&[email protected]&[email protected]&[email protected]&[email protected]">Delete</a></div>
<div class="rep_td0">@Html.TextBox("position_" index, @adminSummary.Position, new { size = 5 })</div>
<div class="rep_td0">@adminSummary.Title</div>
<div class="rep_td0">@adminSummary.DetailCount</div>
<div class="rep_td0">@adminSummary.Modified</div>
<div class="rep_td0">@adminSummary.ModifiedBy</div>
</div>
}
我想找到一個好辦法,一個索引值添加到位置的名稱。
但是,這一直給我的錯誤:CS1026:)預計在
與position_行有沒有人有任何想法我可能是做錯了什麼?
更新:
我試過如下:
<div class="rep_td0">@Html.TextBox("position_"@(index), @adminSummary.Position, new { size = 5 })</div>
這給了錯誤:CS1646:關鍵字,標識符或字符串的預期逐字符後:@
你能給我們多一點的錯誤對話框嗎? – 2011-12-28 07:03:36