LinqDataSource.AutoPage 屬性

定義

取得或設定值,指出 LinqDataSource 控制項是否支援在執行階段完整瀏覽資料的區段。Gets or sets a value that indicates whether the LinqDataSource control supports navigation through sections of the data at run time.

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

屬性值

Boolean

如果使用者可以分頁瀏覽資料,則為 true;否則為 falsetrue if the user can page through the data; otherwise, false. 預設值是 trueThe default value is true.

範例

下列範例顯示 LinqDataSource AutoPage 屬性設為的控制項 true ,以及系結 GridView 至控制項的控制項 LinqDataSourceThe following example shows a LinqDataSource control with the AutoPage property set to true and a GridView control that is bound to the LinqDataSource control. AllowPaging控制項的屬性 GridView 會設定為, true 以提供可讓使用者逐頁查看資料的介面。The AllowPaging property of the GridView control is set to true to provide the interface that lets users page through the data.

<asp:LinqDataSource 
    ContextTypeName="ExampleDataContext" 
    TableName="Products" 
    AutoPage="true"
    AutoSort="true"
    ID="LinqDataSource1" 
    runat="server">
</asp:LinqDataSource>
<asp:GridView 
    AllowPaging="true"
    AllowSorting="true"
    DataSourceID="LinqDataSource1"
    ID="GridView1" 
    runat="server">
</asp:GridView>
<asp:LinqDataSource 
    ContextTypeName="ExampleDataContext" 
    TableName="Products" 
    AutoPage="true"
    AutoSort="true"
    ID="LinqDataSource1" 
    runat="server">
</asp:LinqDataSource>
<asp:GridView 
    AllowPaging="true"
    AllowSorting="true"
    DataSourceID="LinqDataSource1"
    ID="GridView1" 
    runat="server">
</asp:GridView>

備註

AutoPage 屬性設為, true 以啟用控制項中的分頁 LinqDataSourceSet the AutoPage property to true to enable paging in the LinqDataSource control. 若要讓使用者能夠逐頁查看資料,請連接資料繫結控制項,以提供用於分頁至控制項的介面 LinqDataSourceTo enable the user to page through the data, connect a data-bound control that provides the interface for paging to the LinqDataSource control. AutoPage 屬性設定為時 trueLinqDataSource 控制項只會在資料繫結控制項中取得一個頁面的足夠記錄。When the AutoPage property is set to true, the LinqDataSource control retrieves only enough records for one page in the data-bound control. 它會使用 SkipTake 方法來取出目前頁面的記錄。It uses the Skip and Take methods to retrieve the records for the current page.

適用於