
Customizing the Paging Settings and User Interface
You can customize the paging user interface of the GridView control in a number of ways. You can set the size of the page (that is, the number of items to display at once) using the PageSize property. You can also set the current page of the GridView control by setting the PageIndex property. You can specify more custom behavior using either the PagerSettings property or by supplying a pager template.
Paging Modes
The PagerSettings property allows you to customize the appearance of the paging user interface (UI) that is automatically generated by the GridView control when you set the AllowPaging property to true. The GridView control can display direction controls that allow forward and backward navigation as well as numeric controls that allow a user to move to a specific page.
The PagerSettings property of the GridView control is set to a PagerSettings class. You can customize the paging mode by setting the Mode property of the GridView control. For example, you can customize the paging UI mode by setting it as follows:
GridView1.PagerSettings.Mode = PagerButtons.NextPreviousFirstLast
The available modes are:
Pager Control Appearance
The GridView control has numerous properties that you can use to customize the text and images for different pager modes. For example, if you want to allow navigation using direction buttons but want to customize the text that appeared, you can customize the button text by setting the NextPageText and PreviousPageText properties, as in the following example:
GridView1.PagerSettings.NextPageText = "Click for next page"
GridView1.PagerSettings.PreviousPageText = "Click for previous page"
You can also use images to customize the appearance of your paging controls. The PagerSettings class includes image URL properties for the first, last, previous, and next page command buttons.
Finally, you can control the appearance of the paging commands by setting the PagerStyle property of the GridView control to a TableItemStyle value.
Data Paging Template
If you set the AllowPaging property of the GridView control to true, the GridView control automatically adds user interface (UI) controls for paging. You can customize the UI for paging by adding a PagerTemplate template. To specify which paging operation to perform, include a Button control with its CommandName property set to Page and a CommandArgument set to one of the following values:
First To move to the first page.
Last To move to the last page.
Prev To move to the previous page.
Next To move to the next page of data
A number To move to a specific page.