GridView.AllowCustomPaging 屬性

定義

取得或設定值,指出是否啟用自訂分頁。

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

屬性值

如果啟用自訂分頁,則為 true,否則為 false。 預設為 false

備註

分頁可讓您以區塊顯示控制項的內容 GridView 。 頁面上的專案數目取決於 PageSize 屬性。 一般而言,每次控制項移至不同的頁面時 GridView ,都會讀取資料來源中的每個資料列。 當資料來源中的專案總數非常大時,這可能會耗用許多資源。 自訂分頁可讓您唯讀取資料來源中單一頁面所需的專案。

若要啟用自訂分頁,請將 AllowPagingAllowCustomPaging 屬性設定為 true 。 在 事件的處理常式 PageIndexChanging 中,將 PageIndex 屬性設定為新的頁面索引值、將 屬性設定 VirtualItemCount 為數據源中的專案總數、將資料來源設定為只傳回目前頁面所需的資料列,以及呼叫 DataBind 方法。 屬性 VirtualItemCount 可讓控制項判斷頁面總數;此值通常是透過讀取所有專案來自動決定。

適用於