我是新的剃鬚刀引擎語法,我有問題的格式添加視圖中的邏輯。這是我想要完成的。我收集了來自模型的物品。 我需要迭代該集合並在一行中對齊6個項目。MVC格式動態td
這是最後的輸出應該什麼樣子:
<table>
<tr>
<td>checkbox comes here</td>
<td>checkbox comes here</td>
<td>checkbox comes here</td>
</tr>
<tr>
<td>checkbox comes here</td>
<td>checkbox comes here</td>
<td>checkbox comes here</td>
</tr>
................. and so on
</table>
這是我在視圖中寫道:
<table>
@for (int i = 0; i <= Model.checkItems.Count; i++)
{
if (i % 6 == 0)
{ <tr> }
<td>
<input type="checkbox"
id="[email protected](Model.checkItems[i].DisplayText)"
name="chk"
nameVal = "@Model.checkItems[i].DisplayText"
value="@Model.checkItems[i].Value"/>
<label for="[email protected](Model.checkItems[i].DisplayText)">@Model.checkItems[i].DisplayText
</td>
if(i % 6 == 0)
{ </tr> }
}
</table>
當頁面終於得到呈現,第一如果條件獲取代碼執行,但不是第二個。 有人可以幫助弄清楚如何做到這一點?
這工作! – Krishna