---
title: "How to display 20 records each page in mvc4?"  
description: "How to display 20 records each page in mvc4?"  
author: "anil babu"  
published: 2014-01-21  
updated: 2014-01-22  
canonical: https://www.mindstick.com/forum/1851/how-to-display-20-records-each-page-in-mvc4  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 2 minutes  

---

# How to display 20 records each page in mvc4?

How can i display for each [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) 20 [records](https://www.mindstick.com/forum/34640/how-to-create-a-stored-procedure-for-display-all-records) Just like [asp.net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) [gridview](https://www.mindstick.com/articles/873/update-delete-edit-gridview-in-asp-dot-net) Pagesize="20" [property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp), \
\
In the same way i want to display 20 records for each page in MVC4? \
\
How can i do this? \
\

```
@model IEnumerable<Hoda.Models.Products> @{ ViewBag.Title = "products"; Layout = "~/Views/Shared/_Layout.cshtml"; } <p> @Html.ActionLink("Create", "Create") { </p> <table class="table table-striped" style="width:auto"> <tr> <th> @Html.DisplayNameFor(model => model.No) </th> <th> @Html.DisplayNameFor(model => model.ProductName) </th> <th> @Html.DisplayNameFor(model => model.Specifications) </th> <th> @Html.DisplayNameFor(model => model.Quality_ValueAnalysis) </th> <th> @Html.DisplayNameFor(model => model.Aboutus) </th> <th> @Html.DisplayNameFor(model => model.Price) </th> </tr> @if (Model.Count() == 0) { <tr> <td colspan="4">No rows match for this search</td> </tr> } else { foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.No) </td> <td> @Html.DisplayFor(modelItem => item.ProductName) </td> <td> @Html.Raw(item.Specifications) </td> <td> @Html.Raw(item.Quality_ValueAnalysis) </td> <td> @Html.Raw(item.Aboutus) </td> @*<td> @Html.Raw(item.Reviews) </td>*@ <td> @Html.DisplayFor(modelItem => item.Price) </td> <td> @Html.ActionLink("Edit", "Edit", new { id = item.TagNo }) @Html.ActionLink("Details", "Newcars", new { id = item.TagNo}) </td> </tr> } } </table> 
```

[Present](https://answers.mindstick.com/qa/96635/explain-about-the-various-features-present-in-ms-access) i am using to display all records above [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii), \
\
**cs** \
\

```
public ActionResult Index() { var styles = from s in db.demoproducts select s; return View(styles); } 
```

## Replies

### Reply by Abhishek Singh

here is my code for paging. from this you can implement paging in MVC4 like this \

```
 public ActionResult Index(int? page)        {            //if (User.Identity.IsAuthenticated && Roles.IsUserInRole("Administrator"))            //{            var album = db.albums.Include("Genre").Include("Artist").OrderBy(albums => albums.Title);            if (Request.HttpMethod != "GET")            {                page = 1;            }            int pageSize = 10;            int pageNumber = (page ?? 1);            return View(album.ToPagedList(pageNumber, pageSize));            //}            //else            //return RedirectToAction("Index", "Account");        }
```

\
\
and you have to add some more lines in your View @model PagedList.IPagedList<NorthwindApps.Models.Product> // this is used for implement paging if you are finding error //for this class then you have to install this package from NuGet\
and this is the last line for your final implementation of paging

```
 <div style="text-align:center">                    Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)                    of @Model.PageCount                    @Html.PagedListPager(Model, page => Url.Action("Index", new { page }))                </div>
```

\
i hope its helpful for you


---

Original Source: https://www.mindstick.com/forum/1851/how-to-display-20-records-each-page-in-mvc4

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
