我想使用模型创建动态表。我只想每行显示三个记录。行数由列表中的记录数动态标识。我遇到错误了。
Only one @model statement is allowed. Line:16 Col:44
The "td" element was not closed. All elements must be either self-closing
or have a matching end tag. Line:16 Col:10
Encountered end tag "table" with no matching start tag. Are your start/end tags
properly balanced? Line:20 Col:3
The "table" element was not closed. All elements must be either self-closing or have
a matching end tag. Line:8 Col:3
The using block is missing a closing "}" character. Make sure you have a matching "}"
character for all the "{" characters within this block, and that none of the "}"
characters are being interpreted as markup. Line:4 Col:1
我的CSHTML页面如下所示:
@model List<Model>
@using (Html.BeginPanel(true))
{
<table>
<tr>
@for (int i = 0; i < Model.Count; i++)
{
if (i > 0 && i % 3 == 0)
{
@:</tr><tr>
}
<td><div id="dataListItem" >@Model[i].bkgNo</div></td>
}
</tr>
</table>
}
编辑3:根据Stephane的评论更新了代码。将错误标记为粗体。