My Name Is Salman Masood , I am Computer Science &Amp; Maths Graduate from University of Karachi, Pakistan , Teaching Is My Passion and My Aim Is to Deliver All My Knowledge among Those Students Who Can'T Afford Tutors or Expensive Institute Fees. I Will Be Keep Sharing My All Knowledge and Information with You .... Remember Me in Your Prayers !
Friday, 19 October 2018
Pagination in asp net mvc
Action code:
public ActionResult Index(int? page)
{
int pagesize = 6, pageindex = 1;
pageindex = page.HasValue ? Convert.ToInt32(page) : 1;
var list = db.tbl_services.OrderByDescending(x => x.s_id).ToList();
IPagedList<tbl_services> stu = list.ToPagedList(pageindex, pagesize);
return View(stu);
}
View code:
@using PagedList.Mvc
@model PagedList.IPagedList<WebApplication1.Models.tbl_services>
@{
ViewBag.Title = "Home Page";
}
<div class="row">
@foreach (var item in Model)
{
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<img src="@Url.Content(item.s_img)" style="width:200px; height:200px;"/>
<h1 style="text-align:center"> @item.s_name</h1>
</div>
}
</div>
<div>
<div class="pagination" style="margin-left: 400px">
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
of @Model.PageCount @Html.PagedListPager(Model, page => Url.Action("Index", new { page }))
</div>
</div>
Subscribe to:
Post Comments (Atom)
Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC
Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...
-
Load event: pictureBox3.Image = Image .FromFile( @"C:\Users\salman\Documents\Visual Studio 2013\Projects\WindowsFormsApplication3\W...
No comments:
Post a Comment