Easiest Swap Method With MVC3 C #?

You have a website project in MVC3 C # where I extract information from a database and present it in a table in my opinion. I want to use paging to display up to five lines per page. Look for textbooks on the Internet, but they all seem very advanced to achieve this. What is the easiest way to swap with MVC3?

Look in the lower left corner of the image to see what I mean by page

paging http://www.syncfusion.com/content/en-US/products/feature/user-interface-edition/aspnet-mvc/grid/img/Paging_Larger.jpg

+4
source share
2 answers

Try PagedList . There is a NuGet package for MVC.

@{ ViewBag.Title = "Product Listing" } @using PagedList.Mvc; //import this so we get our HTML Helper @using PagedList; //import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic) <!-- import the included stylesheet for some (very basic) default styling --> <link href="/Content/PagedList.css" rel="stylesheet" type="text/css" /> <!-- loop through each of your products and display it however you want. we're just printing the name here --> <h2>List of Products</h2> <ul> @foreach(var product in ViewBag.OnePageOfProducts){ <li>@product.Name</li> } </ul> <!-- output a paging control that lets the user navigation to the previous page, next page, etc --> @Html.PagedListPager( (IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page }) ) 
+8
source

Alternatively, this NuGet package is also very useful and easy to implement. I highly recommend using this utility.

https://github.com/martijnboland/mvcpaging

NuGet [PM> Install-Package MvcPaging]

0
source

Source: https://habr.com/ru/post/1380439/


All Articles