asp.net.ph

DataGrid.CurrentPageIndex Property

System.Web.UI.WebControls Namespace   DataGrid Class


Sets or retrieves the index of the currently displayed page.

Syntax


Script DataGrid.CurrentPageIndex [ = 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 no default value.

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 DataGrid control when paging is enabled. This property is also used to programmatically control which page is displayed.

You can also hide the built in paging controls and create custom controls. To display a specific page, set this property to the page index you want to display and then rebind the data to the DataGrid control.

NOTE: The CurrentPageIndex property is zero based.

Example

The following example demonstrates how to use the CurrentPageIndex property to programmatically control the page to display in the DataGrid control.

void setPage ( Object src, DataGridPageChangedEventArgs e ) {
   // used by built-in pager. Set CurrentPageIndex to the page the user clicked.
   myGrid.CurrentPageIndex = e.NewPageIndex;
   // fetch and rebind the data.
   bindGrid ( );
}
  C# VB

 Show me 

See Also

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