【发布时间】:2020-03-17 13:17:59
【问题描述】:
这是错误。 我正在尝试使用返回视图的 MVC 控制器从数据库中获取数据。
错误 CS1579 foreach 语句无法对“SubscriberEventMapping”类型的变量进行操作,因为“SubscriberEventMapping”不包含“GetEnumerator”的公共实例定义
@model WebApplicationLPISubscriber.Models.SubscriberEventMapping
@using WebApplicationLPISubscriber.Models;
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.SubscriberID)
</th>
<th>
@Html.DisplayNameFor(model => model.SubscriberID)
</th>
<th>
@Html.DisplayNameFor(model => model.EventTypeName)
</th>
<th>
@Html.DisplayNameFor(model => model.Year)
</th>
<th>
@Html.DisplayNameFor(model => model.CalendarStartDate)
</th>
<th>
@Html.DisplayNameFor(model => model.CalendarEndDate)
</th>
</tr>
</table>
foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.SubscriberID)
</td>
<td>
@Html.DisplayFor(modelItem => item.EventTypeName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Year)
</td>
<td>
@Html.DisplayFor(modelItem => item.CalendarStartDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.CalendarEndDate)
</td>
</tr>
}
【问题讨论】:
-
可以分享controller中的Action吗?
标签: html asp.net-mvc razor html-helper