CodeKicks.com
Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Saturday, September 02, 2006

Paging Database Results in ASP.NET

Introduction
One of the most common tasks developers are faced with when working with data-driven Web sites is the need to page data. Most data is only worthwhile if it can easily be digested by a human, so a data-driven Web site needs to present data in an easy-to-read format. In situations where a large chunk of data is presented to the user, it helps to break up this information into multiple pages.

Paging data is nothing new, just about every search engine and eCommerce site employs the technique. If you wonder over to Google and search on ASP you'll get back over five million results! Imagine if Google attempted to show all five million matches on one Web page! Instead, to make the information digestable by human eyes (i.e., yours), Google presents the results in chunks of ten records per page.

In this article we will look at how to implement paging database results using ASP.NET. It is surprisingly simple, requiring just a few lines of code!

Database Paging in Classic ASP
Paging in classic ASP was possible via a number of means. One of the most common ways was to use the paging properties provided in the ADO Recordset object. Even when using these properties, developers still were required to write a lot of code to handle paging correctly. (For more information on paging results using this method in classic ASP, be sure to read this article.) Other methods were available as well, such as using a stored procedure as well client-side script techniques. However, all of these methods required much code and, usually, a hapless intermixing of HTML and script code. Coninue…

Post a Comment