dinsdag, februari 07, 2006


Extending GridView Pager with pagertemplate

Working with the asp:GridView control I wanted to show a more extended pager footer. You can use the PagerSettings to adjust a vew settings:

lastpageimageurl="Last.gif"# //replace # (sry, blogger stuff, and yeah yeah, I need to set up a propper blogsite..)

But sometimes this isn´t enough. To gain more freedom on how to implement your pagerbar, you can make use of a pagertemplate.

Notice the Panel, in this sample code I fill this panel with the pagecontrols I want (previous, first, all pages, next, last)

Now we have to set the OnDataBound eventhandler:


This method will fill the pagerbar with everything you like.

View the script here (dont´t forget to restore the script tags after Copy/Paste):


script in action:


Frank Kroondijk

other ref:

Thanks a lot for this code that you put up there Frank. This was definately something I have been looking for quite a few days. Funny enough it never struck to me that we could use a panel and add link buttons to it in a for loop. Something new I learnt from your code today ... Cheers!
Nice stuff, found this out myself as well. But which control actually catches the Command event that reads the CommandName and CommandArgument from the pressed button? Not the gridview, at least not in my code...
I have done exactly the same thing myself so I was encouraged to find your code. It showed I was on the right track. The problem I am now facing is how to reuse my pager template and the code to handle the dynamic link creation but I don't know how to do it. I could put the grid in a user control but then I would know how to give the grid different columns on different pages. Have you come across this issue?
How would you reuse your pager template and the code to create the dynamic links? If you put the grid into a user control, how would you be able to give the grid different columns on different pages for example? Perhaps you need something more sophisticated than a user control?
Correctly your article helped me very much in my college assignment. Hats incorrect to you send, choice look forward in the direction of more cognate articles without delay as its sole of my favourite question to read.
Een reactie posten

Links to this post:

Een link maken

<< Home