asp.net mvc view strongly typed with PagedList(of product) vb.net
i have this controller function:
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
I have to create a view strongly typed with Dim prod As PagedList(Of product)
<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage(PagedList(Of product))" %>
Where is my mistake?
Try changing your page definition:
<%@ Page
Title=""
Language="VB"
MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage(Of Webdiyer.WebControls.Mvc.PagedList(Of Paging.product))" %>
For starters, your Page Inherit looks a little off. Here's one of mine.
Inherits="System.Web.Mvc.ViewPage(Of MyProject.Domain.User)"
Where Domain.User is a class created by LINQ in my DBML.
Then in my controller I have
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
精彩评论