Hai guys, I have nearly 20 pages in my website .... Every page has a gridview which has thousands of records bind to it... Now i want to implement custom pagination to all those grids.... Guys can some one give a pagination class which can be reusable for all those pages
+2
A:
Your not really going to get a one size fits all class to do this, thats why its called custom paging.
Just a rough guide as to how I have implemented this in the past.
Store the current page number somewhere Querystring/Session/Wherever
When you call your data method/stored procedure to ask for the data pass in the page number and amount of records per page you want.
ammend you stored procedure/data method to only return records in these bounds, it will also need to return a count of the total records so the application knows how many pages there are.
Here is simple example of how you could achieve paging in your stored procedures using SQL2005/2008 (Slightly more to it in 2000)
CREATE PROCEDURE GetTowns
(
@OutTotalRecCount INT OUTPUT,
@CurrentPage INT,
@PageSize INT
)
AS
SELECT * FROM
(
SELECT
ROW_NUMBER() OVER (ORDER BY TownName) AS Row,
TownId,
TownName
FROM Towns
) AS TownsWithRowNumbers
WHERE Row >= (@CurrentPage - 1) * @PageSize + 1 AND Row <= @CurrentPage*@PageSize
SELECT @OutTotalRecCount = COUNT(*) FROM Towns
Gavin Draper
2009-11-06 12:51:49
Hai gavin thanks for ur reply... I ve already written this procedure i only want c# coding to geneate linkbuttons showing page nos....
Pandiya Chendur
2009-11-07 05:13:20
There is a basic example of some VB code you could easily convert to control the link buttons here http://www.c-sharpcorner.com/UploadFile/sd_patel/CustomPagingInDataGrid11232005232703PM/CustomPagingInDataGrid.aspx
Gavin Draper
2009-11-07 08:02:51
Hai Gavin your procedure helped me a lot and i want to use these data show paging links using c# and i would prefer stack overflow pagination.....
Pandiya Chendur
2009-11-09 07:52:14