PagedList 1.0

Rating: No reviews yet
Downloads: 759
Released: Jun 11, 2009
Updated: Jun 11, 2009 by TroyGoode
Dev status: Stable Help Icon

Recommended Download

Source Code PagedList 1.0
source code, 166K, uploaded Jun 11, 2009 - 554 downloads

Other Available Downloads

Application PagedList 1.0
application, 7K, uploaded Jun 11, 2009 - 205 downloads

Release Notes

Project Description

PagedList makes it easier for .Net developers to write paging code. It allows you to take any List<T> and by specifying the page size and desired page index, select only a subset of that list. PagedList also provides properties that are useful when building UI paging controls.

Using PagedList<T>

using System;
using System.Collections.Generic;
using PagedList;

public class Program
	public static void Main(string[] args)
		// create a list of integers from 1 to 200
		var list = new List<int>();
		for(var i = 1; i <= 200; i++)

		var firstPage = list.ToPagedList(0, 20); // first page, page size = 20
		Console.WriteLine("Is first page? {0}", firstPage.IsFirstPage); // true
		Console.WriteLine("Is last page? {0}", firstPage.IsLastPage); // false
		Console.WriteLine("First value on page? {0}", firstPage[0]); // 1

		var anotherPage = list.ToPagedList(4, 20); // fifth page, page size = 20
		Console.WriteLine("Is first page? {0}", anotherPage.IsFirstPage); // false
		Console.WriteLine("Is last page? {0}", anotherPage.IsLastPage); // false
		Console.WriteLine("Total integers in list? {0}", anotherPage.TotalItemCount); // 200
		Console.WriteLine("Integers on this page? {0}", anotherPage.Count); // 20
		Console.WriteLine("First value on page? {0}", anotherPage[0]); // 81

		var lastPage = list.ToPagedList(9, 20); // last (tenth) page, page size = 20
		Console.WriteLine("Is first page? {0}", lastPage.IsFirstPage); // false
		Console.WriteLine("Is last page? {0}", lastPage.IsLastPage); // true
		Console.WriteLine("First value on page? {0}", lastPage[0]); // 181


  • June 11, 2009 Troy Goode posts further tweaks to PagedList<T> code, adds Intellisense documentation, adds source to CodePlex, and creates a signed release binary available for download via CodePlex.
    • Eliminated extraneous call to .Skip(n) when n == 0. Reported by Craig Stuntz.
    • Removed constructor overload to PagedList<T> that accepted IQueryable<T>.
    • Removed protected Initialize method and moved code into only remaining constructor.
    • Optimized constructor to work for IEnumerable<T> or IQueryable<T>.
    • Moved property calculations for PageNumber, HasPreviousPage, HasNextPage, IsFirstPage, and IsLastPage from constructor to property getter. Given that these properties are not likely called in loops, the potential performance hit is likely made up for by the enhanced readability of the constructor code.
    • Removed overload of ToPagedList extension method that took IQueryable<T>.
    • Renamed Pagination static extensions methods class to PagedListExtensions.
    • Added test to verify that when there are two pages of 1 item each, the second page will contain the correct item (the test passed). Suggested by Matt Bertulli.
    • Moved code from System.Collections.Generics namespace to PagedList.
    • Created a solution just for PagedList related classes and signed the assembly using a private key generated just for PagedList.
    • Added XML documentation for all interfaces, classes, methods, and properties.

Reviews for this release

No reviews yet for this release.