NumericPagerField.ButtonType Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the button type to display in the pager field.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

public ButtonType ButtonType { get; set; }

Property Value

Type: System.Web.UI.WebControls.ButtonType

One of the ButtonType values. The default is ButtonType.Link.

Exception Condition
ArgumentOutOfRangeException

The value for the ButtonType property is not one of the ButtonType values.

The following table lists the available button types.

Button type value

Description

ButtonType.Button

A Button control.

ButtonType.Image

An ImageButton control.

ButtonType.Link

A LinkButton control.

When the ButtonType property is set to ButtonType.Image, you must provide the URL of an image for the next-page and previous page buttons. To do this, you can use the NextPageImageUrl and PreviousPageImageUrl properties. The corresponding text property is used as the alternate text for the image. For example, the text that is specified by the NextPageImageUrl property is displayed as the alternate text for the next-page image button. On browsers that support tooltips, this text is also displayed as a tooltip for the corresponding button.

The value of the ButtonType property is stored in view state.

If the DataPager.QueryStringField property is not an empty string or null, the NumericPagerField object ignores the value of the ButtonCount property. In that case, the HyperLink control is used to create the buttons.

The following example shows how to use the ButtonType property to specify that image buttons are displayed in the NumericPagerField object of a DataPager 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 id="Head1" runat="server">
    <title>NumericPagerField Example</title>
    <style type="text/css">
        .header { background-color:#8FBC8F; }
        table { border: solid 1px #000000; } 
    </style>
  </head>
  <body>
    <form id="form1" runat="server">

      <h3>NumericPagerField Example</h3>

      <asp:ListView ID="VendorsListView" 
        DataSourceID="VendorsDataSource"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" width="640px" runat="server" id="tblVendor">
            <tr align="center" class="header" runat="server">
              <td runat="server">ID</td>
              <td runat="server">Vendor Name</td>
              <td runat="server">Active</td>
            </tr>
            <tr id="itemPlaceholder" runat="server">
            </tr>
          </table>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Label ID="VendorIDLabel" runat="server" Text='<%#Eval("VendorID") %>' />
            </td>            
            <td>
              <asp:Label ID="NameLabel" runat="server" Text='<%#Eval("Name") %>' />
            </td>
            <td align="center">
              <asp:CheckBox ID="ActiveFlagCheck" runat="server" 
                Checked='<%#Eval("ActiveFlag") %>' 
                Enabled="false" />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>

      <asp:DataPager runat="server" ID="ContactsDataPager" 
        PagedControlID="VendorsListView" 
        PageSize="10">
        <Fields>
          <asp:NumericPagerField
            NextPageImageUrl="~/images/next.gif" 
            PreviousPageImageUrl="~/images/previous.gif"
            ButtonType="Image" />
        </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="VendorsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
        SelectCommand="SELECT [VendorID], [Name], [ActiveFlag] FROM Purchasing.Vendor">
      </asp:SqlDataSource>

    </form>
  </body>
</html>

.NET Framework
Available since 3.5
Return to top
Show: