I've looked around and have only found examples of pagination for lists of items. But I would like an example of the item's detailed page to be pageable. For ex:
I have an Index page that list all items from Table A that and each item has a "View Detail" button.
When user clicks on "View Detail" button, it takes them to its detail page (I got this working).
And I'd like the user to be able to click "Next" / "Previous" to view the next item's detail page.
Can anyone give me an example or links to examples on how to do this?
UPDATES: 4/6/2014
I'm trying to combine both suggestions that Jasen and Ehsan Sajjad gave, but I'm still stuck. So I'm hoping these codes will help make the description clearer.
I have a Project table and a Work table. Project table can have 0...* Work, but the Work table can only belong to 1 Project.
On the Project Index page, all the projects are listed by the project order (int projectOrder). And when you click on "View Details," it will take you to the project detail page that pulls all of that project's info and the work (from the Work table) belonging to that project. While on that detail page, you will be able to click on the "Next/Prev" button that will take you to the next/prev project detail page (by the project order).
Right now I have:
:: WORK CONTROLLER ::
myContext myDB = new myContext();
public ActionResult Index()
{
var projects = myDB.Projects.OrderBy(p => p.projectOrder).Include("Works");
return View(projects);
}
public ActionResult Projects(string project, int? pOrder)
{
var projectView = myDB.Projects.Include("Works")
.SingleOrDefault(p => p.projectName == project);
//var i = 1;
//int projOrder = projectView.projectOrder;
//int nextPO = projOrder + i;
//var stuff = myDB.Projects.SingleOrDefault(j => j.projectOrder == pOrder);
return View(projectView);
}
The 4 lines commented out were the ones I tried to get the next project by the menu order - but it's not working.
:: VIEW - Work - Index() ::
@model IEnumerable<myStuff.Model.Project>
@foreach (var project in Model)
{
@project.projectName
@Html.ActionLink("View Details", "Projects", "Work", new { project = project.projectName }, null)
}
:: VIEW - Work - Projects() ::
@model myStuff.Model.Project
@Model.projectName
@Html.ActionLink("Next >", "Projects", new { pOrder = Model.projectOrder})
I'm listing all the work (from the Work table) on another page, too, and they have links that will link to their Project's detail page.
I tried to increment/decrement the projectOrder by 1, but I'm not doing this right. So I'm hoping someone can help me.
Thank you again for your time!