Nice GridView pager without images
The predefined options for the GridView , which can be set through the PagerSettings.Mode property are:
- NextPrevious
- NextPreviousFirstLast
- Numeric
- NumericFirstLast
Additionally, you can set the text (FirstPageText, NextPageText,...) or
image URL (FirstPageImageUrl, NextPageImageUrl, ...) to be displayed for
each of those LinkButtons to be shown in the pager.
I wanted to avoid using images and tried to use the Unicode characters
for 'left-pointing pointer' (\u25c4 ◄) and 'right-pointing
pointer' (\u25ba ►). Also, to make it nicer, I wanted to have a
TextBox in which the user can type the page he wants to go to
In the end, I decided to create a class implementing ITemplate, set the
GridView's PagerTemplate to this class and add the controls I needed
manually. The final result looks like this:
Pager with no images.
To use this ITemplate in a GridView, you can do something like:
protected void Page_Init (object sender, EventArgs e) {
myGridView.PagerTemplate = new FancyPagerTemplate (myGridView);
}
...and you're all set. The events generated by a change in the TextBox or
a click on the LinkButtons and the TextBox width will be taken care of.
You can download the source code for the ITemplate from FancyPagerTemplate.cs.
Feel free to customize it to your needs.
[Post Comment] | [Comments]