forum

Home / DeveloperSection / Forums / How to display 20 records each page in mvc4?

How to display 20 records each page in mvc4?

anil babu 2554 21-Jan-2014
How can i display for each page 20 records Just like asp.net gridview Pagesize="20" property, 

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 i am using to display all records above code, 

cs 

public ActionResult Index() 

var styles = from s in db.demoproducts select s; 
return View(styles); 

Updated on 22-Jan-2014

Can you answer this question?


Answer

1 Answers

Liked By