O'Reilly logo

Visual Basic 2008 Recipes: A Problem-Solution Approach by Rakesh Rajan, Matthew MacDonald, Allen Jones, Todd Herman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

6.13. Display Collection Data Using Paging

Problem

You need to segment data from a collection into pages.

Solution

Create a standard query that uses both the Skip and Take clauses to segment the data into appropriately sized pages, and then execute the query in a loop, changing the parameters used with Skip and Take to retrieve and display each page.

How It Works

It is common to divide large amounts of data into manageable chunks, or pages. This is accomplished with LINQ by using a combination of the Skip and Take clauses.

The Skip clause forces the query to skip the specified number of elements, starting from the beginning of the data source. The following example would skip the first three elements of the books collection and then return the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required