System.Web.UI.WebControls Namespace DataGrid Class
Sets or retrieves the number of items to display on a single page of the DataGrid control.
Inline |
<asp:datagrid pagesize = intSize ... > |
Script |
DataGrid.PageSize = intSize |
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.
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.
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 ( );
}
Sub bindGrid ( )
myGrid.PageSize = Integer.Parse ( numPages.SelectedItem.Text )
Dim query As String = "SELECT * FROM pubs_Titles"
myGrid.DataSource = fetchData ( query, "pubs" )
myGrid.DataBind ( )
End Sub |
|
C# |
VB |
Show me
DataGrid Members AllowPaging AllowCustomPaging PageCount PageIndexChanged