I. Building a database and building an MVC project
Create a database of your own and add data. The database I created is as follows.
Second, establish LINQ to SQL mappings.
And then step through it, OK.
Third, write the code
The controller is created in controllers and the template is empty. The project was established as follows:
To add a view index
Select Index in controller and add view, template select list, as follows
Note The background code to add an assembly reference to Mvcpager is as follows:
Using WEBDIYER.WEBCONTROLS.MVC;
public class Studentcontroller:controller { //// GET:/student/public actionresult Index (int id=1) c4/>{ models.studententitydatacontext student= new Models.studententitydatacontext (); Iqueryable<models.s> p = from C in student. S select C; pagedlist<models.s> m = p.topagedlist (id,10); Return View (m); } }
The front code is as follows:
@model pagedlist<mvcapplication1.models.s>@{Layout = null;} @using WEBDIYER.WEBCONTROLS.MVC; Add a reference to an assembly <! DOCTYPE html>Iv. Final Paging effect
Code: http://download.csdn.net/detail/luoyangwyb/7581651
Mvcpager official Download URL: http://mvcpager.codeplex.com/releases/view/47201
Sample URL for Demo: http://en.webdiyer.com/