Click here to Skip to main content
Licence CPOL
First Posted 20 Jun 2005
Views 24,872
Bookmarked 28 times

Generic Paging for Recordset with Next Back Navigation

By | 20 Jun 2005 | Article
This article is basically about a Paging control required for project purposes. One can use this just by changing three parameters.
 
Part of The SQL Zone sponsored by
See Also

Introduction

I had made implementing one of the paging functionalities an assignment during my free time. I have written this article so that one can draw some idea and make some control out of it. .NET has provided ready to go paging functionality for DataGrid, DataList etc. But when one has to create a dynamic table populated with thousands of records without using any ASP.NET control, then we have the write code manually.

Sample Image

Precondition

Connection string: change the connection string in Web.confiq file as per your configuration.

< add key="DSNConn" value="SERVER=localhost;DATABASE=Northwind;UID=sa;PWD=sa" />

Constant: There is one Constant.cs file. This Constant file is a storage area for constants and settings for pagination.

public class Constant
{
    public Constant()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public const int iShowNoPage = 5;//Show No Of pages....
    public static int jIter =iShowNoPage;
    public const int jVirtualInc = iShowNoPage;
    public const int iInitialRecDisplay = 10;
    // How many record you want to display per page..
}

Just make changes to two parameters, one is iShowNoPage = 5/per page (1, 2, 3, 4, 5) and the other is iInitialRecDisplay = 10. The iInitialRecDisplay parameter displays the number of records from the database on the screen.

Implementation

Note: the DropDownList contains three SQL queries which fetch records from three different tables. This is done to show that table 1 can contain 50 records, table 2 can contain 8 records and so on. In our case, total number of records may vary according to the table provided. On the basis of this total number of records, we have calculated the total number of pages mathematically (using Modulus fun). On doing so, one can get the number of pages per screen. For the rest of the logic one can refer the code as it is self explanatory.

Conclusion:

Please let me know if there are any bugs in my paging functionality. I would appreciate any suggestion on this front.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

santosh poojari

Technical Lead

India India

Member

He is presently working as tech arch in one of the leading IT company.He has total 8 years of experience in C#.net. He is a B.E graduate in Computers from Bombay University.
 
Most of his experiences are in designing architect for end to end solutions. His interest areas are WCF,Spring.net,Architecture- Model View Presenter,UML,Webservice,Performance Engineering/tuning,Design patterns,Generics,Enterprise Library,Regular expressions,Silverlight and WWF.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 21 Jun 2005
Article Copyright 2005 by santosh poojari
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid