更新 : 2007 年 11 月
名前空間 :
System.Web.UI.WebControls アセンブリ :
System.Web.Extensions (System.Web.Extensions.dll 内)
<ToolboxBitmapAttribute(GetType(DataPager), "DataPager.ico")> _
<ThemeableAttribute(True)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class DataPager _
Inherits Control _
Implements IAttributeAccessor, INamingContainer, ICompositeControlDesignerAccessor
Dim instance As DataPager
[ToolboxBitmapAttribute(typeof(DataPager), "DataPager.ico")]
[ThemeableAttribute(true)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class DataPager : Control, IAttributeAccessor,
INamingContainer, ICompositeControlDesignerAccessor
[ToolboxBitmapAttribute(typeof(DataPager), L"DataPager.ico")]
[ThemeableAttribute(true)]
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class DataPager : public Control,
IAttributeAccessor, INamingContainer, ICompositeControlDesignerAccessor
/** @attribute ToolboxBitmapAttribute(DataPager, "DataPager.ico") */
/** @attribute ThemeableAttribute(true) */
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal) */
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal) */
public class DataPager extends Control implements IAttributeAccessor,
INamingContainer, ICompositeControlDesignerAccessor
public class DataPager extends Control implements IAttributeAccessor, INamingContainer, ICompositeControlDesignerAccessor
DataPager クラスを使用すると、IPageableItemContainer インターフェイスを実装するデータ バインド コントロールでデータをページングし、ナビゲーション コントロールを表示できます (このインターフェイスを実装するコントロールの例として、ListView コントロールがあります)。
DataPager コントロールをデータ バインド コントロールに関連付けるには、PagedControlID プロパティを使用します。または、DataPager コントロールをデータ バインド コントロール階層の内部に配置することもできます。たとえば、ListView コントロールでは、DataPager コントロールを ListView..::.LayoutTemplate テンプレートの内部に配置できます。
PageSize プロパティを変更すると、データの各ページに表示する項目の数をカスタマイズできます。QueryStringField プロパティを設定して、ページをサーバーに送信する方法を変更することもできます。
ページャ フィールド
DataPager コントロールでナビゲーション コントロールを表示するには、コントロールにページャ フィールドを追加する必要があります。ページャ フィールドは、DataPagerField クラスから派生します。使用できるページャ フィールドの種類の一覧を次の表に示します。
宣言によって DataPager コントロールにページャ フィールドを追加するには、DataPager コントロールに Fields 要素を追加します。次に、その Fields 要素にページャ フィールドを追加します。ページャ フィールドは、Fields 要素に記述されたとおりの順序で Fields コレクションに追加されます。Fields コレクションを使用すると、DataPager コントロール内のページャ フィールドをプログラムによって管理できます。
ページ プロパティ
データ ページの特性を指定する、DataPager コントロールの読み取り専用プロパティの一覧を次の表に示します。通常、これらのプロパティは、TemplatePagerField オブジェクト内のバインド式で使用されます。
ユーザー補助
このコントロールに既定でレンダリングされるマークアップは、Web Content Accessibility Guidelines (WCAG) 1.0 の優先度 1 ガイドラインなどのユーザー補助に関する標準に適合しない可能性があります。このコントロールのユーザー補助サポートの詳細については、「ASP.NET コントロールとユーザー補助」を参照してください。
ListView コントロールにページング機能を追加する方法を次の例に示します。この例では、同一の ListView コントロールのデータのページングに 2 つの DataPager コントロールが使用されています。
<%@ Page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head id="Head1" runat="server">
<title>DataPager Example</title>
<style type="text/css">
th
{
background-color:#eef4fa;
border-top:solid 1px #9dbbcc;
border-bottom:solid 1px #9dbbcc;
}
.itemSeparator { border-right: 1px solid #ccc }
.groupSeparator
{
height: 1px;
background-color: #cccccc;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<h3>DataPager Example</h3>
<!-- The first DataPager control. -->
<asp:DataPager runat="server" ID="BeforeListDataPager"
PagedControlID="ProductsListView"
PageSize="18">
<Fields>
<asp:NextPreviousPagerField ButtonType="Image"
ShowFirstPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false"
FirstPageImageUrl="~/images/first.gif" />
<asp:NumericPagerField ButtonCount="10" />
<asp:NextPreviousPagerField ButtonType="Image"
ShowLastPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false"
LastPageImageUrl="~/images/last.gif" />
</Fields>
</asp:DataPager>
<asp:ListView ID="ProductsListView"
DataSourceID="ProductsDataSource"
GroupItemCount="3"
runat="server">
<LayoutTemplate>
<table cellpadding="2" width="640px" id="tbl1" runat="server">
<tr>
<th colspan="5">PRODUCTS LIST</th>
</tr>
<tr runat="server" id="groupPlaceholder"></tr>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr runat="server" id="tr1">
<td runat="server" id="itemPlaceholder"></td>
</tr>
</GroupTemplate>
<GroupSeparatorTemplate>
<tr runat="server">
<td colspan="5">
<div class="groupSeparator"><hr></div>
</td>
</tr>
</GroupSeparatorTemplate>
<ItemTemplate>
<td align="center" runat="server">
<asp:HyperLink ID="ProductLink" runat="server"
Text='<%# Eval("Name") %>'
NavigateUrl='<%# "ProductDetails.aspx?productID=" & Eval("ProductID") %>' /><br />
<asp:Image ID="ProductImage" runat="server"
ImageUrl='<%#"~/images/thumbnails/" & Eval("ThumbnailPhotoFileName") %>' /><br />
<b>Price:</b> <%# Eval("ListPrice", "{0:c}")%> <br />
</td>
</ItemTemplate>
<ItemSeparatorTemplate>
<td class="itemSeparator" runat="server"> </td>
</ItemSeparatorTemplate>
</asp:ListView>
<!-- The second DataPager control. -->
<asp:DataPager runat="server" ID="AfterListDataPager"
PagedControlID="ProductsListView"
PageSize="18">
<Fields>
<asp:NextPreviousPagerField ButtonType="Image"
ShowFirstPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false"
FirstPageImageUrl="~/images/first.gif" />
<asp:NumericPagerField ButtonCount="10" />
<asp:NextPreviousPagerField ButtonType="Image"
ShowLastPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false"
LastPageImageUrl="~/images/last.gif" />
</Fields>
</asp:DataPager>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="ProductsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT P.ProductID, P.Name, P.Color, P.ListPrice,
PF.ThumbnailPhotoFileName
FROM Production.Product AS P
INNER JOIN Production.ProductProductPhoto AS PPF ON P.ProductID = PPF.ProductID
INNER JOIN Production.ProductPhoto AS PF ON PPF.ProductPhotoID = PF.ProductPhotoID">
</asp:SqlDataSource>
</form>
</body>
</html>
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head id="Head1" runat="server">
<title>DataPager Example</title>
<style type="text/css">
th
{
background-color:#eef4fa;
border-top:solid 1px #9dbbcc;
border-bottom:solid 1px #9dbbcc;
}
.itemSeparator { border-right: 1px solid #ccc }
.groupSeparator
{
height: 1px;
background-color: #cccccc;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<h3>DataPager Example</h3>
<!-- The first DataPager control. -->
<asp:DataPager runat="server" ID="BeforeListDataPager"
PagedControlID="ProductsListView"
PageSize="18">
<Fields>
<asp:NextPreviousPagerField ButtonType="Image"
ShowFirstPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false"
FirstPageImageUrl="~/images/first.gif" />
<asp:NumericPagerField ButtonCount="10" />
<asp:NextPreviousPagerField ButtonType="Image"
ShowLastPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false"
LastPageImageUrl="~/images/last.gif" />
</Fields>
</asp:DataPager>
<asp:ListView ID="ProductsListView"
DataSourceID="ProductsDataSource"
GroupItemCount="3"
runat="server">
<LayoutTemplate>
<table cellpadding="2" width="640px" id="tbl1" runat="server">
<tr>
<th colspan="5">PRODUCTS LIST</th>
</tr>
<tr runat="server" id="groupPlaceholder"></tr>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr runat="server" id="tr1">
<td runat="server" id="itemPlaceholder"></td>
</tr>
</GroupTemplate>
<GroupSeparatorTemplate>
<tr runat="server">
<td colspan="5">
<div class="groupSeparator"><hr></div>
</td>
</tr>
</GroupSeparatorTemplate>
<ItemTemplate>
<td align="center" runat="server">
<asp:HyperLink ID="ProductLink" runat="server"
Text='<%# Eval("Name") %>'
NavigateUrl='<%# "ProductDetails.aspx?productID=" + Eval("ProductID") %>' /><br />
<asp:Image ID="ProductImage" runat="server"
ImageUrl='<%#"~/images/thumbnails/" + Eval("ThumbnailPhotoFileName") %>' /><br />
<b>Price:</b> <%# Eval("ListPrice", "{0:c}")%> <br />
</td>
</ItemTemplate>
<ItemSeparatorTemplate>
<td class="itemSeparator" runat="server"> </td>
</ItemSeparatorTemplate>
</asp:ListView>
<!-- The second DataPager control. -->
<asp:DataPager runat="server" ID="AfterListDataPager"
PagedControlID="ProductsListView"
PageSize="18">
<Fields>
<asp:NextPreviousPagerField ButtonType="Image"
ShowFirstPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false"
FirstPageImageUrl="~/images/first.gif" />
<asp:NumericPagerField ButtonCount="10" />
<asp:NextPreviousPagerField ButtonType="Image"
ShowLastPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false"
LastPageImageUrl="~/images/last.gif" />
</Fields>
</asp:DataPager>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="ProductsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT P.ProductID, P.Name, P.Color, P.ListPrice,
PF.ThumbnailPhotoFileName
FROM Production.Product AS P
INNER JOIN Production.ProductProductPhoto AS PPF ON P.ProductID = PPF.ProductID
INNER JOIN Production.ProductPhoto AS PF ON PPF.ProductPhotoID = PF.ProductPhotoID">
</asp:SqlDataSource>
</form>
</body>
</html>
System..::.Object
System.Web.UI..::.Control
System.Web.UI.WebControls..::.DataPager
この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
Windows Vista, Windows XP SP2, Windows Server 2003
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
.NET Framework
サポート対象 : 3.5
参照
その他の技術情報