PagedList 1.1

Rating:        Based on 2 ratings
Reviewed:  1 review
Downloads: 5333
Released: Aug 4, 2009
Updated: Aug 4, 2009 by TroyGoode
Dev status: Stable Help Icon

Recommended Download

Source Code PagedList 1.1 Source
source code, 169K, uploaded Aug 4, 2009 - 4434 downloads

Other Available Downloads

Application PagedList 1.1 Binaries
application, 8K, uploaded Aug 4, 2009 - 899 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++)
			list.Add(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
		Console.WriteLine();

		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
		Console.WriteLine();

		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
		Console.ReadKey(false);
	}
}

Using StaticPagedList<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 20
		var list = new List<int>();
		for(var i = 1; i <= 20; i++)
			list.Add(i);

		var firstPage = new StaticPagedList(list, 0, 20, 100); // first page
		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
		Console.WriteLine();

		var middlePage = new StaticPagedList(list, 2, 20, 100); // third page, same values
		Console.WriteLine("Is first page? {0}", anotherPage.IsFirstPage); // false
		Console.WriteLine("Is last page? {0}", anotherPage.IsLastPage); // false
		Console.WriteLine("First value on page? {0}", anotherPage[0]); // 1
		Console.WriteLine();

		var lastPage = new StaticPagedList(list, 4, 20, 100); // fifth page, same values
		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]); // 1
		Console.WriteLine();
	}
}

Changes

  • August 4, 2009 Troy Goode adds a StaticPagedList class for working with pre-divided sets of data (like those returned when querying the list of users in Membership).
    • PagedList<T> now derives from BasePagedList<T>, where most of the work is done.
    • StaticPagedList<T> created; also derives from BasePagedList<T>.
    • Added batch scripts for building, testing, and creating a release.

Reviews for this release

     
Thanks for maintaining PagedList and giving it a home on codeplex!
by jrummell on Sep 28, 2009 at 12:13 AM