0

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.

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by MichaelWClark
0

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.

0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.