asp.net.ph

GridView.PageSize Property

System.Web.UI.WebControls Namespace   GridView Class


.NET Framework version 2.0

Sets or retrieves the number of records to display on a single page of a GridView control.

Syntax


Inline <asp:gridview pagesize = intSize ... >
Script GridView.PageSize = intSize

Property Value


intSize Integer specifying the number of rows to display on a single page of the GridView 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 rows to display on a single page of the GridView 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 rows are displayed on a single page of the GridView 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
GridView PageSize, PageCount Example
Run Sample | View Source
See Also

GridView Members   AllowPaging   PageCount   PageIndex   PageIndexChanging 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