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
.gvPagerCss td
padding-left: 5px;
padding-right: 5px;

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


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

Will you give this article a +1 ? Thanks in advance

About The Author

Suprotim Agarwal
Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook

Follow him on twitter @suprotimagarwal

1 comment:

Shweta said...

Thanks a Lot :) its Working !