Using Mvcpager simple paging in MVC

Source: Internet
Author: User
Tags actionlink

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:


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


Mvcpager official Download URL:

Sample URL for Demo:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.