asp.net.ph

DataGrid.PageSize Property

System.Web.UI.WebControls Namespace   DataGrid Class


Sets or retrieves the number of items to display on a single page of the DataGrid control.

Syntax


Inline <asp:datagrid pagesize = intSize ... >
Script DataGrid.PageSize = intSize

Property Value


intSize Integer specifying the number of items to display on a single page of the DataGrid control.

The property is read/write with a default value of 10.

Exceptions


Exception Type Condition
ArgumentOutOfRangeException The given page size is less than 1.

Remarks

Use this property to specify the number of items to display on a single page of the DataGrid control. The AllowPaging property must be set to true for this property have any effect.

Example

The following example demonstrates how to programmatically set the PageSize property to specify how many items are displayed on a single page of the DataGrid control at run time, based on user input.

void bindGrid ( ) {
   myGrid.PageSize = int.Parse ( numPages.SelectedItem.Text );
   string query = "SELECT * FROM pubs_Titles";
   myGrid.DataSource = fetchData ( query, "pubs" );
   myGrid.DataBind ( );
}
  C# VB

 Show me 

See Also

DataGrid Members   AllowPaging   AllowCustomPaging   PageCount   PageIndexChanged 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