• Multiple constructors accepting all given System.Collections.Generic.List


    出现上述错误的原因是给的List未定义或未找到

    在学习ASP.Net Core Razor Page时,使用了ViewModel,按照mvc的逻辑,更改了View的model类型,

    系统报上述错误,是自己理解错误,在Razor Page中model应该为IndexModel之类的。自己逻辑有问题;

    @page
    @model ContosoUniversity.Pages.Courses.IndexModel
    //这里应该是IndexModel,后面使用model.CourseVM,访问自定义的视图模型
    //这里误写为 List<ContosoUniversity.Model.CourseVM,出现上述错误
    
    @{
        ViewData["Title"] = "Courses";
    }
    
    <h1>Courses</h1>
    
    <p>
        <a asp-page="Create">Create New</a>
    </p>
    <table class="table">
        <thead>
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.CourseVM[0].CourseId)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.CourseVM[0].Title)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.CourseVM[0].Credits)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.CourseVM[0].DepartmentName)
                </th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.CourseVM)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.CourseId)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Title)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Credits)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.DepartmentName)
                    </td>
                    <td>
                        <a asp-page="./Edit" asp-route-id="@item.CourseId">Edit</a> |
                        <a asp-page="./Details" asp-route-id="@item.CourseId">Details</a> |
                        <a asp-page="./Delete" asp-route-id="@item.CourseId">Delete</a>
                    </td>
                </tr>
            }
        </tbody>
    </table>
    
  • 相关阅读:
    我来说说博客评论的事
    SWFUpload+Javascript仿163邮件上传文件
    如何暂停和终止线程
    分享我的数据处理类库,欢迎拍砖
    求数列两两之差,再求和
    poj 1006 中国剩余定理
    Poj算法做题顺序
    poj 1328
    ZOJ 3279
    poj 2352 树状数组
  • 原文地址:https://www.cnblogs.com/AlexanderZhao/p/12878899.html
Copyright © 2020-2023  润新知