Digg style custom paging for GridViews in ASP.NET
I’ve been on a bit of a digg kick lately and I like how they handle paging so I decided to create a GridView control that uses custom paging similar to digg’s. The algorithm is based on this post. As far as html output goes, this should be fairly close to the actual output on digg and I’m using digg’s stylesheet in the demo.
About the algorithm (from Stranger Studios):
- The pagination object has a “previous” and “next” button which takes the user to the next page. The previous button is disabled on the first page. Similarly, the next button is disabled on the last page.
- The pagination object will always display links to the first two pages and the last two pages of the set.
- The pagination object will always display links to the first x (adjacents in the code) pages before and after the current page.
- The pagination object will only show at most 5+2x links (first two + prior x + current page + next x + last two). All links not shown will be replaced by …
A little preview:
You can download the project here. I didn’t spend a ton of time testing this code, please leave any bug reports in the comments – Thanks!
Update: Changed the code a bit – paging is now handled via query string instead of posting back. Not a huge deal but the code is easier to read.
- .net , asp.net , digg , technical
- Comments(8)