I created a stored procedure to handle paging and sorting. Linked a LinqToSql to it and bound my gridview from that. I use my Gridview.PageSize to determine how many results to pull from the table through my stored procedure. The issue is because of this a pager never gets created. I wrote another procedure to determine how many pages will be needed based on the page size and was trying to manually create the pager...but it was being a pain. Does anyone know how to effectively force a Gridview's pager? The prformance gains from using my stored procedure for this is great so I would like to keep that as is.

Hey Michael

visit below link..It has nice explaination about Paging with Storedprocedure..I believe it will help to you..

http://www.codeproject.com/KB/database/CustomPagingStoredProc.aspx

I created a stored procedure to handle paging and sorting. Linked a LinqToSql to it and bound my gridview from that. I use my Gridview.PageSize to determine how many results to pull from the table through my stored procedure. The issue is because of this a pager never gets created. I wrote another procedure to determine how many pages will be needed based on the page size and was trying to manually create the pager...but it was being a pain. Does anyone know how to effectively force a Gridview's pager? The prformance gains from using my stored procedure for this is great so I would like to keep that as is.

hey try this source code
1. ALTER PROCEDURE dbo.EfficientGridViewPaging
2.
3. @pageIndex int,
4. @pageSize int
5.
6. AS
7.
8. BEGIN
9.
10. WITH Entries AS (
11.
12. SELECT ROW_NUMBER() OVER (ORDER BY ID DESC)
13. AS RowNumber, random_data1, random_data2, random_data_etc
14. FROM the_table
15. )
16.
17. SELECT random_data1, random_data2, random_data_etc
18.
19. FROM Entries
20.
21. WHERE RowNumber BETWEEN (@pageIndex - 1) * @pageSize + 1 AND @pageIndex * @pageSize
22.
23. END


Online Movies

Thank you both for the links but the issue was not with the paging it self. The stored procedure preforms just as it should. The issue I was having is that I wanted the gridview to still show a pager so I could page the information. I was not able to override the pager and make it display as I wanted. I ended up just creating a custom pager that resides in a div right under my gridview. This actually worked out nice because I had done the same with the header and then put a scrollbar on the gridview. Now I have a static Header and Pager which looks very nice. I would still like to know if there is a way to override the pager to make it display 1,2,3,....X.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.