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

DetailsView コントロールの下部のページ行を表す DetailsViewRow。

(AllowPaging プロパティを true に設定することによって) ページングが有効になっている場合、ページ行と呼ばれる追加行が自動的に DetailsView コントロールに表示されます。ページ行は、ユーザーが他のレコードに移動できるコントロールを含み、コントロールの上部、下部、または上部と下部の両方に表示できます。DetailsView コントロールの下部のページ行を表す DetailsViewRow オブジェクトにプログラムでアクセスするには、BottomPagerRow プロパティを使用します。
![]() |
---|
BottomPagerRow プロパティは、ItemCreated イベントで DetailsView コントロールによって下部のページ行が作成された後にしか使用できません。 |
このプロパティは通常、下部のページ行をプログラムから操作する必要がある場合 (カスタム コンテンツを追加する場合など) に使用されます。BottomPagerRow プロパティへの変更は、DetailsView コントロールを表示した後で行う必要があります。そうしないと、DetailsView コントロールによって変更が上書きされます。

BottomPagerRow プロパティを使用して、ItemCreated イベント中に DetailsView コントロールの下部のページ行にアクセスする方法のコード例を次に示します。カスタム ページ行の中の 2 つの Label コントロールが、現在のページ番号とページの総数で更新されます。
<%@ Page language="VB" %> <script runat="server"> Protected Sub CustomerDetailView_DataBound(ByVal sender As Object, ByVal e As EventArgs) ' Get the pager row. Dim pagerRow As DetailsViewRow = CustomerDetailView.BottomPagerRow ' Get the Label controls that display the current page information ' from the pager row. Dim pageNum As Label = CType(pagerRow.Cells(0).FindControl("PageNumberLabel"), Label) Dim totalNum As Label = CType(pagerRow.Cells(0).FindControl("TotalPagesLabel"), Label) If (pageNum IsNot Nothing) And (totalNum IsNot Nothing) Then ' Update the Label controls with the current page values. Dim page As Integer = CustomerDetailView.DataItemIndex + 1 Dim count As Integer = CustomerDetailView.DataItemCount pageNum.Text = page.ToString() totalNum.Text = count.ToString() End If End Sub </script> <html> <body> <form id="Form1" runat="server"> <h3>DetailsView PagerTemplate Example</h3> <!-- Notice that the LinkButton controls in the pager --> <!-- template have their CommandName properties set. --> <!-- The DetailsView control automatically recognizes --> <!-- certain command names and performs the appropriate --> <!-- operation. In this example, the CommandName --> <!-- properties are set "Page" and the CommandArgument --> <!-- properties are set to "Next" and "Prev", which --> <!-- causes the DetailsView control to navigate to the --> <!-- next and previous record, respectively. --> <asp:detailsview id="CustomerDetailView" datasourceid="DetailsViewSource" autogeneraterows="true" allowpaging="true" runat="server" OnDataBound="CustomerDetailView_DataBound"> <headerstyle backcolor="Navy" forecolor="White"/> <pagerstyle VerticalAlign="Bottom" /> <pagertemplate> <table width="100%"> <tr> <td> <asp:LinkButton id="PreviousButton" text="<" CommandName="Page" CommandArgument="Prev" runat="Server"/> <asp:LinkButton id="NextButton" text=">" CommandName="Page" CommandArgument="Next" runat="Server"/> </td> <td align="right"> Page <asp:Label id="PageNumberLabel" runat="server" /> of <asp:Label id="TotalPagesLabel" runat="server" /> </td> </tr> </table> </pagertemplate> </asp:detailsview> <!-- 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="DetailsViewSource" runat="server" ConnectionString= "<%$ ConnectionStrings:NorthWindConnectionString%>" InsertCommand="INSERT INTO [Customers]([CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country]) VALUES (@CustomerID, @CompanyName, @Address, @City, @PostalCode, @Country)" SelectCommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"> </asp:SqlDataSource> </form> </body> </html>
<%@ Page language="C#" %> <script runat="server"> protected void CustomerDetailView_DataBound(object sender, EventArgs e) { // Get the pager row. DetailsViewRow pagerRow = CustomerDetailView.BottomPagerRow; // Get the Label controls that display the current page information // from the pager row. Label pageNum = (Label)pagerRow.Cells[0].FindControl("PageNumberLabel"); Label totalNum = (Label)pagerRow.Cells[0].FindControl("TotalPagesLabel"); if ((pageNum != null) && (totalNum != null)) { // Update the Label controls with the current page values. int page = CustomerDetailView.DataItemIndex + 1; int count = CustomerDetailView.DataItemCount; pageNum.Text = page.ToString(); totalNum.Text = count.ToString(); } } </script> <html> <body> <form id="Form1" runat="server"> <h3>DetailsView PagerTemplate Example</h3> <!-- Notice that the LinkButton controls in the pager --> <!-- template have their CommandName properties set. --> <!-- The DetailsView control automatically recognizes --> <!-- certain command names and performs the appropriate --> <!-- operation. In this example, the CommandName --> <!-- properties are set "Page" and the CommandArgument --> <!-- properties are set to "Next" and "Prev", which --> <!-- causes the DetailsView control to navigate to the --> <!-- next and previous record, respectively. --> <asp:detailsview id="CustomerDetailView" datasourceid="DetailsViewSource" autogeneraterows="true" allowpaging="true" runat="server" OnDataBound="CustomerDetailView_DataBound"> <headerstyle backcolor="Navy" forecolor="White"/> <pagerstyle VerticalAlign="Bottom" /> <pagertemplate> <table width="100%"> <tr> <td> <asp:LinkButton id="PreviousButton" text="<" CommandName="Page" CommandArgument="Prev" runat="Server"/> <asp:LinkButton id="NextButton" text=">" CommandName="Page" CommandArgument="Next" runat="Server"/> </td> <td align="right"> Page <asp:Label id="PageNumberLabel" runat="server" /> of <asp:Label id="TotalPagesLabel" runat="server" /> </td> </tr> </table> </pagertemplate> </asp:detailsview> <!-- 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="DetailsViewSource" runat="server" ConnectionString= "<%$ ConnectionStrings:NorthWindConnectionString%>" InsertCommand="INSERT INTO [Customers]([CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country]) VALUES (@CustomerID, @CompanyName, @Address, @City, @PostalCode, @Country)" SelectCommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"> </asp:SqlDataSource> </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に収録されているすべての辞書からDetailsView.BottomPagerRow プロパティを検索する場合は、下記のリンクをクリックしてください。

- DetailsView.BottomPagerRow プロパティのページへのリンク