asp.net mvc view 强烈类型化的PagedList(of product) vb.net的视图。

问题描述 投票:0回答:2

我有这样一个控制器函数,我必须用Dim prod As PagedList(Of product)创建一个强类型的视图。

Public Function Index(ByVal id As System.Nullable(Of Integer)) As ActionResult 
using db = New DbDataContext() 
Dim prod As PagedList(Of product) = db.products.ToPagedList(If(id, 1), 20) 
Return View(prod) 
End Using
End Function

我必须创建一个强类型的视图 Dim prod As PagedList(Of product)

<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage(PagedList(Of product))" %>

我的错误在哪里?

asp.net-mvc vb.net view
2个回答
0
投票

尝试改变你的页面定义。

<%@ Page 
    Title="" 
    Language="VB" 
    MasterPageFile="~/Views/Shared/Site.Master" 
    Inherits="System.Web.Mvc.ViewPage(Of Webdiyer.WebControls.Mvc.PagedList(Of Paging.product))" %>

0
投票

首先,你的Page Inherit看起来有点不对劲。 下面是我的一个例子。

Inherits="System.Web.Mvc.ViewPage(Of MyProject.Domain.User)"

其中Domain.User是在我的DBML中由LINQ创建的一个类。

然后在我的控制器中我有

Function Details(ByVal id As Integer) As ActionResult
    Dim user As Domain.User = UserService.GetUserByID(id)
    user.LastSeen = (From am In user.ActivityLogs
                        Select am.ActivityDate
                        Order By ActivityDate Descending).FirstOrDefault

    If Not user Is Nothing Then

        Return View(user)
    Else
        Response.StatusCode = CInt(HttpStatusCode.NotFound)
        Return RedirectToAction("NotFound", "Error")
    End If

End Function
© www.soinside.com 2019 - 2024. All rights reserved.