小编Ste*_*hen的帖子

获取IEnumerable错误:CS1061不包含C#ASP.NET MVC5

我无法找到解决问题的方法,我尝试了很多替代方案,但我无法解决.

我首先使用模型生成我的数据库,之后我使用Scaffolding生成视图(索引,创建,编辑,删除..).唯一的视图(索引)与模型使用IEnumerable.

索引视图是:

@model IEnumerable<CAD_CMDBv2.Models.Location>

@{
    ViewBag.Title = "Location's Management";
}

<h2>All Locations</h2>

<p>
    @Html.ActionLink("Create Location", "Create")
</p>

    <table class="table">
         <tr>
              <th>
                    @Html.DisplayNameFor(model => model.Location.site_name)
              </th>
              <th>
                    @Html.DisplayNameFor(model => model.Location.country_name)
              </th>
              <th>
                    @Html.DisplayNameFor(model => model.Location.region_name)
              </th>
              <th></th>
        </tr>

        @foreach(var item in Model) {
            <tr>
                 <td>
                      @Html.DisplayFor(modelItem => item.Location.site_name)
                 </td>
                 <td>
                      @Html.DisplayFor(modelItem => item.Location.country_name)
                 </td>
                 <td>
                      @Html.DisplayFor(modelItem => item.Location.region_name)
                 </td>
                 <td>
                      @Html.ActionLink("Edit", "Edit", new { id = item.Location.location_id }) |
                      @Html.ActionLink("Details", "Details", new { id = item.Location.location_id }) |
                      @Html.ActionLink("Delete", "Delete", …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc ienumerable asp.net-mvc-4

5
推荐指数
1
解决办法
2663
查看次数

标签 统计

asp.net ×1

asp.net-mvc ×1

asp.net-mvc-4 ×1

c# ×1

ienumerable ×1