0
我有以下代码:ASP.NET - HTML.Display不显示值
@model IEnumerable<SampleMvcApp.Models.Exercise>
@foreach (var item in Model.GroupBy(m => m.DayName).Distinct())
{
<table class="table">
<h2>@Html.Display(item.Select(x => x.DayName).ToString())</h2>
<thead>
<tr>
<th>
ExerciseName
</th>
<th>
ExerciseTime
</th>
<th>
ExerciseRepetition
</th>
<th>
MomentOfTheDay
</th>
<th>
Routine
</th>
<th>
Week
</th>
</tr>
</thead>
@foreach (var test2 in item)
{
<tbody>
<tr>
<td>
@Html.DisplayFor(modelItem => test2.ExerciseName)
</td>
<td>
@Html.DisplayFor(modelItem => test2.ExerciseTime)
</td>
<td>
@Html.DisplayFor(modelItem => test2.ExerciseRepetition)
</td>
<td>
@Html.DisplayFor(modelItem => test2.MomentOfTheDay)
</td>
<td>
@Html.DisplayFor(modelItem => test2.Routine.RoutineID)
</td>
<td>
@Html.DisplayFor(modelItem => test2.ExerciseWeek)
</td>
<td>
<a asp-action="Edit" asp-route-id="@test2.ExerciseID">Edit</a> |
<a asp-action="Details" asp-route-id="@test2.ExerciseID">Details</a> |
<a asp-action="Delete" asp-route-id="@test2.ExerciseID">Delete</a>
</td>
</tr>
</tbody>
}
</table>
}
一切工作正常,但
<h2>@Html.Display(item.Select(x => x.DayName).ToString())</h2>
我只是想展现天名称上表因为它按天分组,但显示代码不会显示任何内容。我试过使用DisplayFor,但显然它不接受表达式。或者,也许我做错了。
我几乎有正确的做法哈哈。非常感谢你清除那个。 – LeinadDC