Hi @Peter Newman,
Because I don't know your model and data,
I wrote an example of using PagedList in VB.Net MVC View with test data.
@ModelType PagedList.IPagedList(Of WebVBDemo.QuestionViewModel)
@Imports PagedList.Mvc
@Code
ViewData("Title") = "Transaction Sets"
End Code
<Table Class="table">
@For Each item In Model
@<tr>
<td>
@Html.DisplayFor(Function(modelItem) item.QuestionName)
</td>
</tr>
Next
</Table>
Page @(If(Model.PageCount < Model.PageNumber, 0, Model.PageNumber)) of @Model.PageCount
@Html.PagedListPager(Model, Function(page) Url.Action("Contact", New With {page}))
Function Contact(ByVal page As Integer?) As ActionResult
Dim questions = {
New QuestionViewModel With {
.QuestionId = 1,
.QuestionName = "Question 1"
}, New QuestionViewModel With {
.QuestionId = 1,
.QuestionName = "Question 2"
}, New QuestionViewModel With {
.QuestionId = 1,
.QuestionName = "Question 3"
}, New QuestionViewModel With {
.QuestionId = 1,
.QuestionName = "Question 4"
}}
Dim PageSize As Integer = 2
Dim PageNumber As Integer = (If(page, 1))
Return View(questions.ToPagedList(PageNumber, PageSize))
End Function
Public Class QuestionViewModel
Public Property QuestionId As Integer
Public Property QuestionName As String
End Class
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.