FormView.BottomPagerRow 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 FormViewRow 对象,该对象表示在 FormView 控件底部显示的页导航行。
public:
virtual property System::Web::UI::WebControls::FormViewRow ^ BottomPagerRow { System::Web::UI::WebControls::FormViewRow ^ get(); };
[System.ComponentModel.Browsable(false)]
public virtual System.Web.UI.WebControls.FormViewRow BottomPagerRow { get; }
[<System.ComponentModel.Browsable(false)>]
member this.BottomPagerRow : System.Web.UI.WebControls.FormViewRow
Public Overridable ReadOnly Property BottomPagerRow As FormViewRow
属性值
一个 FormViewRow 对象,表示 FormView 控件的底部页导航行。
- 属性
示例
下面的示例演示如何使用 BottomPagerRow 属性访问控件底部 FormView 显示的页码行。 然后,使用其他内容更新寻呼行。
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void EmployeeFormView_DataBound(Object sender, EventArgs e)
{
// Get the pager row.
FormViewRow pagerRow = EmployeeFormView.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 = EmployeeFormView.PageIndex + 1;
int count = EmployeeFormView.PageCount;
pageNum.Text = page.ToString();
totalNum.Text = count.ToString();
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>FormView PagerTemplate Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>FormView PagerTemplate Example</h3>
<asp:formview id="EmployeeFormView"
datasourceid="EmployeeSource"
allowpaging="true"
datakeynames="EmployeeID"
ondatabound="EmployeeFormView_DataBound"
runat="server">
<itemtemplate>
<table>
<tr>
<td>
<asp:image id="EmployeeImage"
imageurl='<%# Eval("PhotoPath") %>'
alternatetext='<%# Eval("LastName") %>'
runat="server"/>
</td>
<td>
<h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3>
<%# Eval("Title") %>
</td>
</tr>
</table>
</itemtemplate>
<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>
<pagersettings position="Bottom"
mode="NextPrevious"/>
</asp:formview>
<!-- 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="EmployeeSource"
selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>
</form>
</body>
</html>
<%@ Page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub EmployeeFormView_DataBound(ByVal sender As Object, ByVal e As EventArgs)
' Get the pager row.
Dim pagerRow As FormViewRow = EmployeeFormView.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 = EmployeeFormView.PageIndex + 1
Dim count As Integer = EmployeeFormView.PageCount
pageNum.Text = page.ToString()
totalNum.Text = count.ToString()
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>FormView PagerTemplate Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>FormView PagerTemplate Example</h3>
<asp:formview id="EmployeeFormView"
datasourceid="EmployeeSource"
allowpaging="true"
datakeynames="EmployeeID"
ondatabound="EmployeeFormView_DataBound"
runat="server">
<itemtemplate>
<table>
<tr>
<td>
<asp:image id="EmployeeImage"
imageurl='<%# Eval("PhotoPath") %>'
alternatetext='<%# Eval("LastName") %>'
runat="server"/>
</td>
<td>
<h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3>
<%# Eval("Title") %>
</td>
</tr>
</table>
</itemtemplate>
<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>
<pagersettings position="Bottom"
mode="NextPrevious"/>
</asp:formview>
<!-- 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="EmployeeSource"
selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>
</form>
</body>
</html>
注解
当将 属性设置为 true
) 时, (AllowPaging启用分页时,控件中FormView会自动显示名为“寻呼行”的附加行。 寻呼行包含允许用户导航到其他记录的控件,并且可以显示在控件的顶部、底部或同时显示在控件的顶部和底部。
BottomPagerRow使用 属性以编程方式访问FormViewRow表示控件中底部页码行的对象FormView。
备注
属性BottomPagerRow仅在 控件在 事件中创建ItemCreated底部页码行后FormView才可用。
当需要以编程方式操作底部页码行时(例如添加自定义内容时),通常使用此属性。 对 属性的任何修改 BottomPagerRow 都必须在创建表示底部页码行的对象之后 FormViewRow 执行;否则,控件 FormView 将覆盖所有更改。