ObjectDataSource.EnablePaging Property
Assembly: System.Web (in system.web.dll)
/** @property */ public boolean get_EnablePaging () /** @property */ public void set_EnablePaging (boolean value)
public function get EnablePaging () : boolean public function set EnablePaging (value : boolean)
Property Value
true if the data source control supports paging through the data it retrieves; otherwise, false.Paging by the ObjectDataSource control is handled by setting the EnablePaging, StartRowIndexParameterName, MaximumRowsParameterName, and SelectCountMethod properties of the ObjectDataSource and defining a select method in the business object with the proper parameters. When the EnablePaging property is set to true, the SelectParameters collection includes two additional parameters for the first row that is requested and the number of rows that are requested. These two parameters are named as defined by the StartRowIndexParameterName and MaximumRowsParameterName properties. The Select method should return the requested number of rows, starting at the specified index. Because the data might not divide evenly by the page size, the last page might contain fewer rows. Thus, the number of rows that are requested is actually the maximum number of rows that are returned.
When paging is enabled on the associated data-bound control, the data-bound control calls the Select method with the start index and number of rows that are required. Additionally, if the SelectCountMethod property is set, the data-bound control calls the method before rendering the pager controls. For example, if a GridView control has paging enabled with a page size of 5, and the method that is specified by the SelectCountMethod property returns 20, only 4 pages are displayed in the pager.
The EnablePaging property delegates to the EnablePaging property of the ObjectDataSourceView object.
This section contains two code examples. The first code demonstrates how to implement a type that enables paging. The second code example demonstrates how to create an instance of the ObjectDataSource class and set properties.
The following code example demonstrates how to implement a type that enables paging. The PagingData.Select method takes two parameters, startRowIndex and maximumRows. The PagingData class also defines a method named SelectCount, which returns the total number of rows in the data. The following code shows the PagingData class:
The following code example demonstrates how to create an instance of the ObjectDataSource class and sets the following properties for paging:
-
The TypeName property is set to PagingData.
-
The SelectCountMethod is set to SelectCount.
-
The EnablePaging is set to true.
The values for the MaximumRowsParameterName and StartRowIndexParameterName properties are left as their defaults, maximumRows and startRowIndex, respectively.
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.