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

About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.

1 comment:

Unknown said...

Thanks a Lot :) its Working !