MVC 分页

48 篇文章 1 订阅
45 篇文章 0 订阅
@Imports PagedList.Mvc
@ModelType PagedList.IPagedList(Of VBLinqTest. QueryResult )


<h2>Index</h2>


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


@Html.PagedListPager(Model, Function(page) Url.Action("Index", New With {page}), PagedListRenderOptions.ClassicPlusFirstAndLast)


        <Table Class="table">
            <tr>
                <th>
                    OrderID
                </th>
                <th>
                    CustomerID
                </th>
                <th>
                    ProductID
                </th>
                <th>
                    ProductName
                </th>
                @*<th>
                        UnitPrice
                    </th>*@


                <th></th>
            </tr>


            @For Each item In Model
    @<tr>
        <td>
            @Html.DisplayFor(Function(modelItem) item.OrderID)
        </td>
        <td>
            @Html.DisplayFor(Function(modelItem) item.CustomerID)
        </td>
        <td>
            @Html.DisplayFor(Function(modelItem) item.CompanyName)
        </td>
        <td>
            @Html.DisplayFor(Function(modelItem) item.ProductID)
        </td>
        @*<td>
                @Html.DisplayFor(Function(modelItem) item.)
            </td>*@


        <td>
            @Html.ActionLink("Edit", "Edit", New With {.id = item.OrderID}) |
            @Html.ActionLink("Details", "Details", New With {.id = item.OrderID}) |
            @Html.ActionLink("Delete", "Delete", New With {.id = item.OrderID})
        </td>
    </tr>
            Next


        </Table>

------------------------- control

        Function Index(Optional ByVal page As Integer = 1) As ActionResult
            Dim aa As String = "A,O"
            Dim whereCondition As String() = aa.Split(","c)


            Dim query222 = (From order In db.Orders
                            From vendor In db.Order_Details.Where(Function(v) v.OrderID = order.OrderID).DefaultIfEmpty()
                            From status In db.Customers.Where(Function(s) s.CustomerID = order.CustomerID).DefaultIfEmpty()
                            Select New QueryResult With {.OrderID = order.OrderID, .CustomerID = order.CustomerID,
                               .ProductID = vendor.ProductID, .CompanyName = status.CompanyName,
                                .alldata = order.OrderID & order.CustomerID & vendor.ProductID & status.CompanyName}
                                ).Where(Function(tt) tt.OrderID <= 10250).OrderBy(Function(v) v.OrderID)
            Dim result = From p In query222
                         Where whereCondition.Any(Function(s) p.alldata.Contains(s))
                         Select p


            Dim all = result.ToPagedList(page, 6)

            Return View(all)
        End Function

------------------------- model

Public Class QueryResult
    Property OrderID As String
    Property CustomerID As String
    Property CompanyName As String
    Property ProductID As String
    'Property ProductName As String
    Property UnitPrice As String
    Property alldata As String
End Class

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值