asp.net.ph

DataGrid.AllowPaging Property

System.Web.UI.WebControls Namespace   DataGrid Class


Sets or retrieves a value specifying whether paging is enabled.

Syntax


Inline <asp:datagrid allowpaging = true | false ... >
Script DataGrid.AllowPaging [ = true | false ]

Property Value

This property accepts or returns only a boolean value: true if paging is enabled; otherwise, false. Default value is false.

Remarks

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.

NOTE: 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.

Example

The following example demonstrates how to set the AllowPaging property at design time to enable paging.

<asp:datagrid id = "myGrid" runat = "server"
   ...
   allowpaging pagesize=4
   onPageIndexChanged = "setPage">

 Show me 

See Also

DataGrid Members   PageIndexChanged   AllowCustomPaging   PageSize   CurrentPageIndex Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph