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?
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
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))" %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.