Partager via


DataPagerFieldCollection.Add(DataPagerField) Méthode

Définition

Ajoute l'objet DataPagerField spécifié à la collection.

public:
 void Add(System::Web::UI::WebControls::DataPagerField ^ field);
public void Add (System.Web.UI.WebControls.DataPagerField field);
member this.Add : System.Web.UI.WebControls.DataPagerField -> unit
Public Sub Add (field As DataPagerField)

Paramètres

field
DataPagerField

Objet à ajouter à la collection.

Exemples

L’exemple suivant montre comment utiliser la Add méthode pour ajouter un NextPreviousPagerField objet à un DataPager contrôle.

void Page_Load(Object sender, EventArgs e)
{
  
  // Dynamically generated field pagers need to be created only 
  // the first time the page is loaded.
  
  if (!IsPostBack)
  {
    // Create a NextPreviousPagerField object to display
    // the buttons to navigate.
    NextPreviousPagerField pagerField = new NextPreviousPagerField();
    pagerField.ShowFirstPageButton = true;
    pagerField.ShowLastPageButton = true;
    pagerField.ButtonType = ButtonType.Button;

    // Add the pager field to the Fields collection of the
    // DataPager control.
    ContactsDataPager.Fields.Add(pagerField);
  }

  ContactsListView.DataBind();

}
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
  
  ' Dynamically generated field pagers need to be created only 
  ' the first time the page is loaded.

  If Not IsPostBack Then
    ' Create a NextPreviousPagerField object to display
    ' the buttons to navigate.
    Dim pagerField As New NextPreviousPagerField()
    pagerField.ShowFirstPageButton = True
    pagerField.ShowLastPageButton = True
    pagerField.ButtonType = ButtonType.Button

    ' Add the pager field to the Fields collection of the
    ' DataPager control.
    ContactsDataPager.Fields.Add(pagerField)
  End If
      
  ContactsListView.DataBind()

End Sub

Remarques

L’objet DataPagerField est ajouté à la fin de la collection.

S’applique à

Voir aussi