使用asp.net MVC的 HtmlHelper 时报错:Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.

解决办法:


I had the same problem with something like

@foreach (var item in Model)
{
    @Html.DisplayFor(m => !item.IsIdle, "BoolIcon")
}
I solved
this just by doing @foreach (var item in Model) { var active = !item.IsIdle; @Html.DisplayFor(m => active , "BoolIcon") }

猜你喜欢

转载自www.cnblogs.com/dayang12525/p/10277861.html