This is a mirror of official site: http://jasper-net.blogspot.com/

Display large amount of data in GridView with search functionality

| Wednesday, September 15, 2010
Introduction

This article explains how to display thousands or millions of data in GridView in ASP.Net 3.5.

In Part - 1, our main goal is to achieve super fast performance of gridview when it display large amount of data. When user navigates through data, they should not have feeling that they are navigating to millions of data.

In Part - 2, we will implement search functionality over the GridView.

To achieve this goal, we will leverage custom paging, caching and AJAX. We will also implement sorting in this part. I have used AdventureWorks sample database for SQLServer 2008.

Background

Basic knowledge of ASP.Net 3.5, C#, Custom Paging, GridView, Caching, AJAX, SQL Server 2008 and VS2008 is required.

Other than these, I have used DataPager with GridView for custom paging. Originally you can not use DataPager with GridView directly because DataPager can be used with control which implements IPageableItemContainer interface. So we have to create new custom control which derives from GridView and also implements IPageableItemContainer.

For more info visit here .


Overview

Let’s first understand the whole process behind it. When GridView will be displayed first time, we will check whether the data is already being cached or not. If not then we will fetch all the records from database and store it in cache.

We will display limited records depends on page index and page size on each request. We will calculate StartingRowIndex and MaximumRecords for custom paging as below:

SatrtingRowIndex = (PageIndex -1)*PageSize;
MaximumRecords = PageSize.

If page index is 1 and page size is 10 then startingRowIndex will be 0 and MaximumRecords will be 10, so we will return 10 rows from datatable from 0 to 9. Likewise if page index is 2 and page size is 10 then startingRowIndex will be 10 and MaximumRecords will be 10, so we will return 10 rows from datatable starting from 10 to 19.

So every time we will bind only 10 records to GridView but we will display page number based on total records in the database. This is where custom paging and DataPager comes into picture.

Read more: Codeproject

Posted via email from .NET Info

0 comments: