views:

18

answers:

2

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 mystake?

A: 

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
rockinthesixstring
look at object returns to viewit isDim prod As PagedList(Of product)
Massimo
A: 

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))" %>
Darin Dimitrov
thanks now i see collections and can cicle it
Massimo