Highlight Current Page in ASP.NET GridView Pager

Continuing my ASP.NET GridView Tips and Tricks series, this post shows how to highlight the current page in an ASP.NET GridView Pager.

There are some cool CSS tips that you can apply on the ASP.NET GridView pager to improve the look and feel of GridView paging. Here’s how the GridView paging appears with no css applied

gridview pager

Now add the following CSS in the <head> element on your page

<style type="text/css"> 
.gvPagerCss span
{
background-color:#DEE1E7;
font-size:20px;
}
.gvPagerCss td
{
padding-left: 5px;
padding-right: 5px;
}
</style>

Now set the GridView <PagerStyle> to this CSS class, which will modify the style of the pager

image

That’s it. Now browse your GridView and the paging should look much better than it did earlier. As seen below, the current page gets highlighted and there is extra spacing between the page numbers.

gridview pager

1 comment: