PagerSettings.PageButtonCount 属性
定义
获取或设置在 Mode 属性设置为 Numeric 或 NumericFirstLast 值时页导航中显示的页按钮的数量。Gets or sets the number of page buttons to display in the pager when the Mode property is set to the Numeric or NumericFirstLast value.
public:
property int PageButtonCount { int get(); void set(int value); };
public int PageButtonCount { get; set; }
member this.PageButtonCount : int with get, set
Public Property PageButtonCount As Integer
属性值
要在页导航中显示的页按钮的数量。The number of page buttons to display in the pager. 默认值为 10。The default is 10.
例外
PageButtonCount 设置为一个小于 1 的值。The PageButtonCount is set to a value that is less than 1.
示例
下面的代码示例演示如何使用属性在 PageButtonCount 控件的页导航行中一次显示五个页面按钮 GridView 。The following code example demonstrates how to use the PageButtonCount property to display five page buttons at a time in the pager row of a GridView control.
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>PagerSetting Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>PagerSetting Example</h3>
<asp:gridview id="CustomerGridView"
datasourceid="CustomerDataSource"
autogeneratecolumns="true"
datakeynames="CustomerID"
allowpaging="true"
runat="server">
<pagersettings mode="NumericFirstLast"
firstpagetext="First"
lastpagetext="Last"
pagebuttoncount="5"
position="Bottom"/>
</asp:gridview>
<br/>
<asp:label id="MessageLabel"
forecolor="Red"
runat="server"/>
<!-- 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="CustomerDataSource"
selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
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">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>PagerSetting Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>PagerSetting Example</h3>
<asp:gridview id="CustomerGridView"
datasourceid="CustomerDataSource"
autogeneratecolumns="true"
datakeynames="CustomerID"
allowpaging="true"
runat="server">
<pagersettings mode="NumericFirstLast"
firstpagetext="First"
lastpagetext="Last"
pagebuttoncount="5"
position="Bottom"/>
</asp:gridview>
<br/>
<asp:label id="MessageLabel"
forecolor="Red"
runat="server"/>
<!-- 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="CustomerDataSource"
selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>
</form>
</body>
</html>
注解
当 Mode 属性设置为 Numeric 或 NumericFirstLast 值时,请使用 PageButtonCount 属性指定要在页导航中显示的页按钮的数量。When the Mode property is set to the Numeric or NumericFirstLast value, use the PageButtonCount property to specify the number of page buttons to display in the pager.
此属性的值存储在视图状态中。The value of this property is stored in view state.