1
votes

I am using a GridView to display data from database. Using ASP.Net 4.0 with C#. The GV is given DataTable as its data source. I need to display numerical paging to this grid where the user can see Next and Previous buttons along with "page number links" like

<< Prev 1 2 3 ... Next >>

on top right section of the grid. Is there any way to do this using custom paging or any built in feature of GV? What kind of event I need to handle for the page number clicks? Can anybody please point me to right direction or code snippet?

Thanks ...

2

2 Answers

2
votes
 `allowpaging="true"` in gridview

then write you pagersettings as

<pagersettings mode="NumericFirstLast"
            firstpagetext="First"
            lastpagetext="Last"
            pagebuttoncount="5"  
            position="Bottom"/> 

you can see detail here

(Optional) on server side

place your page change logic in PageIndexChanged

1
votes
  1. Set AllowPaging property to true.

  2. Set GridView.PagerSettings.Mode = PagerButtons.NumericFirstLast

  3. Set position="Top" and add the following to markup

    <PagerStyle HorizontalAlign="Right" /> 
    
  4. Attach to the PageIndexChanged event to handle page numeric clicks

Here is good example.

You can find more details here: http://msdn.microsoft.com/en-us/library/5aw1xfh3.aspx