AllowPaging Property

DataGrid::AllowPaging Property

Gets or sets a value that indicates whether paging is enabled.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

virtual property bool AllowPaging {
	bool get ();
	void set (bool value);

Property Value

Type: System::Boolean
true if paging is enabled; otherwise, false. The default value is false.

Paging allows you to display the contents of the DataGrid control in page segments. The number of items on a page is determined by the PageSize property. If no value is specified for the PageSize property, the DataGrid control will display 10 items on a page.

By default, paging is disabled. To enable paging, set this property to true and provide code to handle the PageIndexChanged event.

The typical logic for the PageIndexChanged event is to set the CurrentPageIndex property to the index of the page you want to display and then use the DataBind method to bind the data to the DataGrid control.


The event handler receives a DataGridPageChangedEventArgs object as a parameter. You can use the NewPageIndex property of this parameter to determine the index of the page selected by the user from the page selection elements of the DataGrid control.

With standard paging, the DataGrid control assumes that the data source contains all the items to be displayed. The DataGrid control calculates the indexes of the items on the displayed page based on the page index, specified by the CurrentPageIndex property, and the number of items of items on a page, specified by the PageSize property.

Normally, a data source that contains all items to be displayed is loaded every time the DataGrid control is paged. This can consume a lot of resources when the data source is very large. Custom paging allows you to load just the segment of data needed to display a single page. For additional information on custom paging, see the AllowCustomPaging property.

The following code example demonstrates how to use the AllowPaging property to enable paging.

No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
© 2015 Microsoft