GridView.AllowPaging プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As GridView Dim value As Boolean value = instance.AllowPaging instance.AllowPaging = value
/** @property */ public boolean get_AllowPaging () /** @property */ public void set_AllowPaging (boolean value)
ページング機能が有効な場合は true。それ以外の場合は false。既定値は false です。

GridView コントロールでは、データ ソース内のすべてのレコードを同時に表示せずに、自動的にレコードを複数のページに分割できます。データ ソースでページング機能がサポートされている場合、GridView コントロールは、その機能を利用して組み込みのページング機能を提供できます。ページング機能は、System.Collections.ICollection インターフェイスをサポートするデータ ソース オブジェクト、またはページング機能をサポートするデータ ソースで使用できます。
ページング機能を有効にするには、AllowPaging プロパティを true に設定します。既定では、GridView コントロールは一度に 1 ページあたり 10 個のレコードを表示します。PageSize プロパティを設定して、ページに表示されるレコード数を変更できます。データ ソースの内容を表示するために必要な合計ページ数を確認するには、PageCount プロパティを使用します。PageIndex プロパティを使用して、現在表示されているページのインデックスを確認できます。
ページングが有効になっている場合、ページ行と呼ばれる追加行が自動的に GridView コントロールに表示されます。ページ行には、ユーザーが他のページに移動できるコントロールが含まれています。ページ行の設定 (ページャ表示モード、一度に表示するページ リンクの数、ページャ コントロールのテキスト ラベルなど) は、PagerSettings プロパティを使用して制御できます。ページ行は、Position プロパティを設定することによって、コントロールの上部、下部または上部と下部の両方に表示できます。また、Mode プロパティを設定して、4 つの組み込みのページャ表示モードのいずれかを選択することもできます。この組み込みの表示モードを次の表に示します。
PagerButton.NextPrevious | |
PagerButton.NextPreviousFirstLast | |
PagerButton.Numeric | 直接ページにアクセスするための番号付きリンク ボタンで構成されるページ編集コントロール セット。これは、既定のモードです。 |
PagerButton.NumericFirstLast |
ページ行の外観 (背景色、フォントの色、位置など) を制御するには、PagerStyle プロパティを使用します。
GridView コントロールでは、ページ行用のカスタム テンプレートも定義できます。カスタム ページ行テンプレートの作成の詳細については、PagerTemplate のトピックを参照してください。
GridView コントロールには、ページングが発生したときにカスタム アクションを実行するために使用できる複数のイベントが用意されています。使用できるイベントの一覧を次の表に示します。
PageIndexChanged | ページャ ボタンの 1 つがクリックされた場合に、GridView コントロールがページング操作を処理した後に発生します。通常、このイベントは、ユーザーがコントロール内の別のページに移動した後にタスクを実行する必要がある場合に使用されます。 |
PageIndexChanging | ページャ ボタンの 1 つがクリックされた場合に、GridView コントロールがページング操作を処理する前に発生します。このイベントは、ページング操作をキャンセルする場合によく使用されます。 |
Topic | Location |
---|---|
方法 : GridView Web サーバー コントロールで既定のページングを有効にする | Visual Studio での ASP .NET Web アプリケーションの作成 |

AllowPaging プロパティを使用して、GridView コントロールのページング機能を宣言によって有効にする方法を次のコード例に示します。
<%@ Page language="VB" %> <html> <body> <form runat="server"> <h3>GridView AllowPaging Example</h3> <asp:gridview id="CustomersGridView" datasourceid="CustomersSource" autogeneratecolumns="true" emptydatatext="No data available." allowpaging="true" runat="server"> <pagersettings mode="Numeric" position="Bottom" pagebuttoncount="10"/> <pagerstyle backcolor="LightBlue" height="30px" verticalalign="Bottom" horizontalalign="Center"/> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="CustomersSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ Page language="C#" %> <html> <body> <form runat="server"> <h3>GridView AllowPaging Example</h3> <asp:gridview id="CustomersGridView" datasourceid="CustomersSource" autogeneratecolumns="true" emptydatatext="No data available." allowpaging="true" runat="server"> <pagersettings mode="Numeric" position="Bottom" pagebuttoncount="10"/> <pagerstyle backcolor="LightBlue" height="30px" verticalalign="Bottom" horizontalalign="Center"/> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="CustomersSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>

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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からGridView.AllowPaging プロパティを検索する場合は、下記のリンクをクリックしてください。

- GridView.AllowPaging プロパティのページへのリンク