Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ObjectDataSource::EnablePaging Property

Gets or sets a value that indicates whether the data source control supports paging through the set of data that it retrieves.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
public:
property bool EnablePaging {
	bool get ();
	void set (bool value);
}
<asp:ObjectDataSource EnablePaging="True|False" />

Property Value

Type: System::Boolean
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.

The following three examples show a Web page, a code-behind page class, and a data-access class that enable the user to pick how many records are displayed in the page.

The Web page contains an ObjectDataSource control whose EnablePaging property is set to true. The SelectCountMethod property is set to the name of a method that returns the total number of records in the query. The MaximumRowsParameterName property and the StartRowIndexParameterName property are set to the names of the parameters that are used in the Select method. The page also contains a DropDownList control.

No code example is currently available or this language may not be supported.

The second example shows a handler for the ListControl::SelectedIndexChanged event of the DropDownList control. The code in the handler sets the PageSize property to the user's selection.

No code example is currently available or this language may not be supported.

The third example shows the data access class that retrieves data from the Customers table. It includes a method named GetSubsetOfEmployees, which is assigned to the SelectMethod property of the ObjectDataSource control. The example also includes a method named GetEmployeeCount, which is assigned to the SelectCountMethod property of the ObjectDataSource control. The class uses LINQ to query the Customers table. The example requires a LINQ to SQL class that represents the Northwind database and Customers table. For more information, see How to: Create LINQ to SQL Classes in a Web Project.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.