asp.net.ph

GridView.PageIndex Property

System.Web.UI.WebControls Namespace   GridView Class


.NET Framework version 2.0

Sets or retrieves the index of the currently displayed page.

Syntax


Script GridView.PageIndex [ = intIndex ]

This property can only be used programmatically; it cannot be set when declaring the control.

Property Value


intIndex The index of the page currently displayed.

The property is read/write with a default value of 0 ( zero ).

Exceptions


Exception Type Condition
ArgumentOutOfRangeException The given page index is a negative value.

Remarks

Use this property to determine the currently displayed page in the GridView control when paging is enabled. This property is also used to programmatically control which page is displayed.

To display a specific page, set this property to the page index you want to display and then rebind the data to the GridView control.

NOTE: The PageIndex property is zero based.

Example

The following example demonstrates how to use the PageIndex property to determine the currently displayed page in a GridView control .

void getPage ( Object src, EventArgs e ) {
   lblTracker.Text = "Page " + ( myGrid.PageIndex + 1 ) + 
      " of " + myGrid.PageCount;
}
  C# VB
GridView PageIndex Example
Run Sample | View Source
See Also

GridView Members   AllowPaging   PageCount   PageSize Skip Navigation Links




Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

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