Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DataPagerFieldCollection.Add Method

Appends the specified DataPagerField object to the collection.

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

public void Add(
	DataPagerField field
)

Parameters

field
Type: System.Web.UI.WebControls.DataPagerField

The object to append to the collection.

The DataPagerField object is added to the end of the collection.

The following example shows how to use the Add method to add a NextPreviousPagerField object to a DataPager control.

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();

}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5
Show:
© 2015 Microsoft