1 Replies - 1801 Views - Last Post: 15 August 2012 - 12:03 PM Rate Topic: -----

#1 skyxn3t  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 14-August 12

How to create a custom Pager for GridView?

Posted 14 August 2012 - 03:45 PM

Is it possible to create a custom Pager for the GridView control of ASP.NET that looks liek this?


Posted Image

If so, can anyone give me some ideas or some starting code into how to create it?

Thank you.
Is This A Good Question/Topic? 0
  • +

Replies To: How to create a custom Pager for GridView?

#2 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1172
  • View blog
  • Posts: 1,658
  • Joined: 24-August 11

Re: How to create a custom Pager for GridView?

Posted 15 August 2012 - 12:03 PM

You'll have to modify the GridView's PagerStyle and PagerSettings. First, create a method that takes a GridView as an argument, and updates the pagerstyle and pagersettings.

public void StyleGridView(GridView myGridView)
{
    myGridView.PagerStyle.BackColor = Color.Black;
    myGridView.PagerStyle.ForeColor = Color.White;

    myGridView.PagerSettings.NextPageImageUrl = "~MyNextPageImage.png";
    myGridView.PagerSettings.PreviousPageImageUrl = "~MyPreviousPageImage.png";

    *whatever other attributes you set*
}



Then, in the Page_Load, run the method and pass the gridview to it. This isn't everything you'll need to set, but it's a start.

EDIT: Added links to the respective MSDN pages.

Also, you can do it from the .aspx page with some CSS (which is probably what you'll want to do anyway).

Inside the gridview tags, use <PagerSettings /> and <PagerStyle />, and set the pagerstyle cssclass to .someclassname. The page numbers can be styled with .someclassname a, and the current page with .someclassname span. The border-radius attribute will be handy for this...

This post has been edited by h4nnib4l: 15 August 2012 - 01:01 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1