通过


PagerSettings.Mode 属性

定义

获取或设置在支持分页的控件中显示寻呼控件的模式。

public:
 property System::Web::UI::WebControls::PagerButtons Mode { System::Web::UI::WebControls::PagerButtons get(); void set(System::Web::UI::WebControls::PagerButtons value); };
public System.Web.UI.WebControls.PagerButtons Mode { get; set; }
member this.Mode : System.Web.UI.WebControls.PagerButtons with get, set
Public Property Mode As PagerButtons

属性值

其中一个 PagerButtons 值。 默认值为 PagerButtons.Numeric

例外

设置为 Mode 不是值 PagerButtons 之一的值。

示例

下面的代码示例演示如何使用 Mode 属性指定控件的 GridView 寻呼行应显示数字按钮。


<%@ 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 指定模式。 下表描述了分页控件的不同模式。

模式 说明
NextPrevious 上一页和下一页按钮。
NextPreviousFirstLast 上一页、下一页、第一页和最后一页按钮。
Numeric 用于直接访问页面的编号链接按钮。
NumericFirstLast 编号和第一链接和最后链接按钮。

当属性 设置为 / > 或 值时,可以通过设置下表中显示的属性来指定非数值按钮的自定义文本。

财产 说明
FirstPageText 第一页按钮的文本。
PreviousPageText 上一页按钮的文本。
NextPageText 下一页按钮的文本。
LastPageText 最后一页按钮的文本。

或者,还可以通过设置下表中显示的属性来显示非数值按钮的图像。

财产 说明
FirstPageImageUrl 要为第一页按钮显示的图像的 URL。
PreviousPageImageUrl 要为上一页按钮显示的图像的 URL。
NextPageImageUrl 要显示下一页按钮的图像的 URL。
LastPageImageUrl 要为最后一页按钮显示的图像的 URL。

注释

设置图像属性时,相应的文本属性充当图像的备用文本。 例如,设置属性时 FirstPageImageUrl ,属性指定的 FirstPageText 文本将显示为图像的备用文本。 在支持工具提示的浏览器中,此文本也显示为相应按钮的工具提示。

此属性的值存储在视图状态中。

适用于

另请参阅