如何通过仅从数据库中每次获取10行来对mvc3 gridview进行分页

时间:2013-07-08 04:23:40

标签: asp.net-mvc-3 sql-server-2008 razor

下面我已经获取了数据源Model.slst,因为它包含大约1000行,但它太慢,因为每次都应该获取1000行,所以我想在每次分页时只获取10行,但我不知道如何做到这一点。

@{
    var grid = new WebGrid(source: Model.slst, rowsPerPage: 10, canPage: false, canSort: true,ajaxUpdateContainerId: "lgrid");
 }

           <h3>Services</h3>
            @grid.GetHtml(
                tableStyle: "lgrid",
                headerStyle: "head",
                alternatingRowStyle: "alt",
                columns: grid.Columns(
                grid.Column("S.N.", format: @<text>@{count++;}@count</text>, style: "sn"),
                grid.Column("Services", format: @<text>@item.ServiceName</text>),
                grid.Column("Edit", format: (item) => Html.ActionLink("Edit", "EditServices",
                         new { id = item.ServiceId }, new { @class = "openDialog", data_dialog_id = "emailDialog", data_dialog_title = "Edit" })),
                         grid.Column("Delete", format: (item) => Html.ActionLink("Delete", "DeleteServices", new { id = item.ServiceId }, new { @class = "openDialog", data_dialog_id = "emailDialog", data_dialog_title = "Delete" }))
                         ))

1 个答案:

答案 0 :(得分:0)