异常信息:Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions

解决办法:


由以下代码:
@foreach (var item in Model)
{
    @Html.DisplayFor(m => !item.IsIdle, "BoolIcon")
}
改为: @foreach (var item in Model) { var active = !item.IsIdle; @Html.DisplayFor(m => active , "BoolIcon") }

 或者

由以下代码:

<div class="controls" style="width:20%">
@{ int index = @Model.chapter_index + 1;}
@Html.TextBoxFor(model => index, new { @class = "span11" })
</div>

改为:

<div class="controls" style="width:20%">
@{ int index = @Model.chapter_index + 1;}
@Html.TextBoxFor(model => index, new { @class = "span11" })
</div>

 

相关文章: