Paging Behavior in DataGrid Web Server Controls
The DataGrid Web server control allows you to add paging to the grid using these methods:
|Default paging and default navigation buttons||The DataGrid control displays navigation buttons as part of the DataGrid control. These controls are either Next and Previous buttons or page numbers. When the user clicks these buttons, the grid updates the current page number and raises an event so you can refresh the data.|
|Default paging and custom navigation controls||You enable paging and set the page size of the DataGrid control. Then you place navigation controls, such as Next and Previous buttons, on the Web Forms page. In the click events for these buttons, you manipulate the current page of the DataGrid control. The control then selects the appropriate data rows to display.|
|Custom paging||You provide your own navigation controls, manually set which page to display, and provide the rows for just that page. This option allows you to move any number of pages at a time, jump to a specific page, and so on.|
For details on specifying paging behavior, see Specifying Paging Behavior in a DataGrid Web Server Control.
Default versus Custom Paging
The page displayed by the grid is determined by its CurrentPageIndex property. The default paging controls set this property automatically; if you are providing custom paging controls, you set it yourself. After the CurrentPageIndex is set, the grid is re-bound to the data source. The grid recreates the entire dataset and automatically moves to the appropriate place in the dataset. It then displays enough rows to make one page of the grid.
If you are working with a large dataset, recreating the entire dataset each time users navigate to a new page can degrade performance. By using custom paging, you can retrieve data in page-size "chunks" — that is, retrieve just a page worth of records at a time. To do that, you turn off the automatic paging feature of the grid so that it doesn't assume that it is working with the entire dataset. You then get the correct number of rows to fill the grid. For information on implementing custom paging, see DataGrid.AllowCustomPaging Property.