Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GridView Paging - First, Last, Next, Previous

Is it possible to add:

"First, Last, Next, Previous" options to the GridView paging? I can't seem to figure it out. All I can get are numbers and >> for last and << for first...

like image 717
Madam Zu Zu Avatar asked Apr 15 '11 14:04

Madam Zu Zu


3 Answers

Set the value of the PageText properties of the PagerSettings section:

<asp:GridView ID="gridView" runat="server" AllowPaging="True">
    <PagerSettings  Mode="NextPreviousFirstLast" FirstPageText="First" PreviousPageText="Previous" NextPageText="Next" LastPageText="Last" />
</asp:GridView>

You can set these values from the Properties window in the designer too ..

like image 163
Akram Shahda Avatar answered Nov 20 '22 21:11

Akram Shahda


The default Pager of GridView is not flexible.

The alternatives are these

  1. Using Pager Template of the GridView (GridView PagerTemplate Property by MSDN)
  2. Extending the GridView control to support DataPager (example here)
like image 4
naveen Avatar answered Nov 20 '22 22:11

naveen


Yes it is possible using PagerSettings property of gridview, all you need to do is- set Mode of PagerSetting to 'NextPreviousFirstLast' so that you can use "First, Last, Next, Previous" option for paging with gridview.

  <PagerSettings  Mode="NextPreviousFirstLast" FirstPageText="First" PreviousPageText="Previous" NextPageText="Next" LastPageText="Last" />

There are three more properties of Mode like "NextPrevious" , "Numeric" and "NumericFirstLast"

to use them ..

NextPrevious :

 <PagerSettings Mode="NextPrevious" PreviousPageText="Previous" NextPageText="Next"/>

Numeric :

  <PagerSettings  Mode="Numeric" />

NumericFistLast :

      <PagerSettings  Mode="NumericFistLast" />
like image 2
Chetan Bodke Avatar answered Nov 20 '22 22:11

Chetan Bodke