ObjectDataSourceView.EnablePaging 属性

定义

获取或设置一个值,该值指示数据源控件是否支持对它检索的数据集进行分页。Gets or sets a value indicating whether the data source control supports paging through the set of data that it retrieves.

public:
 property bool EnablePaging { bool get(); void set(bool value); };
public bool EnablePaging { get; set; }
member this.EnablePaging : bool with get, set
Public Property EnablePaging As Boolean

属性值

如果数据源控件支持对它检索的数据进行分页,则为 true;否则为 falsetrue, if the data source control supports paging through the data it retrieves; otherwise, false.

注解

ObjectDataSourceView通过Select设置的、MaximumRowsParameterName、和SelectCountMethod属性,并使用正确的参数定义业务对象中的方法,对控件进行分页。ObjectDataSourceView EnablePaging StartRowIndexParameterNamePaging by the ObjectDataSourceView control is handled by setting the EnablePaging, StartRowIndexParameterName, MaximumRowsParameterName, and SelectCountMethod properties of the ObjectDataSourceView and defining a Select method in the business object with the proper parameters. 当属性设置为true时, 该SelectParameters集合包括两个附加参数, 用于请求的第一行和请求的行数。 EnablePagingWhen the EnablePaging property is set to true, the SelectParameters collection includes two additional parameters for the first row requested and the number of rows requested. 这两个参数的命名方式由StartRowIndexParameterNameMaximumRowsParameterName属性定义。These two parameters are named as defined by the StartRowIndexParameterName and MaximumRowsParameterName properties. Select方法应返回从指定索引处开始的请求的行数。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 requested is actually the maximum number of rows that are returned.

DataSourceSelectArguments在调用ExecuteSelect方法的过程中检查属性,以确保数据源控件支持通过设置各种属性而请求的所有功能。CanRetrieveTotalRowCountThe CanRetrieveTotalRowCount property is checked during a call to the ExecuteSelect method to ensure that the data source control supports all capabilities requested by setting the various DataSourceSelectArguments properties.

如果对关联的数据绑定控件启用了分页, 则数据绑定控件将调用Select具有所需的起始索引和行数的方法。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. 此外, 如果设置SelectCountMethod了属性, 数据绑定控件将在呈现页导航控件之前调用方法。Additionally, if the SelectCountMethod property is set, the data-bound control calls the method before rendering the pager controls. 例如, 如果GridView控件启用了分页, 页面大小为 5, 并且该SelectCountMethod方法返回 20, 则在页导航中只显示4页。For example, if a GridView control has paging enabled with a page size of 5, and the SelectCountMethod method returns 20, only 4 pages are displayed in the pager.

EnablePaging属性的值存储在视图状态中。The value of the EnablePaging property is stored in view state.

适用于

另请参阅