dcsimg
 

Submitted by: Srinath M S(srinath_ms@yahoo.com)

Monday Oct 14th 2019 by Srinath M S

Language: .NET, Expertise: Intermediate - With the Skip and Take methods in LINQ, paging has become a lot easier. Learn how to use them to provide paging to your items.

With the Skip and Take methods in LINQ, paging has become a lot easier.

All we need to do is have a simple logic such as is outlined below. This will provide the paged items.

var pagedItems = theListWithLotsOfItems.Skip ((pageNumber - 1) * pageSize).Take(pageSize);

pageNumber(1) and pageSize(10) will provide first 10 items, and pageNumber(2) and pageSize(10) will provide second page data - another 10 items and so on.
Home
Mobile Site | Full Site