簡體   English   中英

在ASP.NET MVC應用程序(模型)中進行排序,篩選和分頁

[英]Sorting, Filtering, and Paging in an ASP.NET MVC Application (Model)

在ASP.NET MVC 5應用程序中進行排序,篩選和分頁。

我的代碼:

@model PagedList.IPagedList<PublicRelations.Models.Suggestion>
@using PagedList.Mvc;
...
...
...
    <table class="table table-hover table-striped table-responsive">
        <tr>
            <th>

                @Html.ActionLink(model => model.Name, "Index", new { sortOrder = ViewBag.NameSortParm })
            </th>
            <th>
    ...
    ...
    ...
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.Name)
                    </td>
                    <td>
    ...
    ...
    ...
    </table>
    Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
            @Html.PagedListPager(Model, page => Url.Action("Index", new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))

錯誤:

@Html.ActionLink(model => model.Name, "Index", new { sortOrder = ViewBag.NameSortParm })

錯誤:無法將lambda表達式轉換為“字符串”類型,因為它不是委托類型。 ????

確保已導入System.Linq命名空間

如果已經存在,那么請提供一些其他信息以了解確切的問題區域。

希望會有所幫助。

我使用此頁面的代碼進行排序和過濾等。在文本中手動輸入的兩種方式鏈接。 我是根據標題鏈接確定模特兒標題的。

在ASP.NET MVC應用程序中使用實體框架進行排序,篩選和分頁

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM