DataPagerFieldCollection.Add(DataPagerField) メソッド

定義

指定した DataPagerField オブジェクトをコレクションに追加します。

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)

パラメーター

field
DataPagerField

コレクションに追加するオブジェクト。

次の例は、 メソッドを使用 Add してオブジェクトを NextPreviousPagerField コントロールに追加する方法を DataPager 示しています。

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

注釈

DataPagerFieldオブジェクトがコレクションの末尾に追加されます。

適用対象

こちらもご覧ください