I would suggest you use the PagedList library. Its so awesome that Microsoft decided to use the library in their official tutorials (full tutorial here)
It provides a very clean code while doing pagination. See sample codes below.
Step 1
Add the PagedList.Mvc library using Nuget. https://www.nuget.org/packages/PagedList.Mvc/
Step 2
Integrate PagedList in your action method. Here is an example on how you could do it.
using PagedList;
public ActionResult ShowNews(int? page)
{
int currentPage = (page ?? 1);
// Fix negative page
currentPage = currentPage < 0 ? 1 : currentPage;
int pageSize = 3;
IEnumerable<Models.News> newsModels = newsService.GetList(currentPage, pageSize);
return View(newsModels.ToPagedList(currentPage, pageSize));
}
Step 3
Integrate PagedList in your View
@model PagedList.IPagedList<Models.News>
@using PagedList.Mvc;
@foreach (var item in Model.News)
{
<div class="row">
<div class="col-sm-1" style="padding-left: 5px;margin-left: 5px;">
<img src="@item.Image" />
</div>
<div class="col-sm-5">
@Html.ActionLink(item.Abstract, MVC.Admin.News.Index())
</div>
</div>
}
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action(MVC.Admin.News.ActionNames.ShowNews))
See complete tutorial here http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application