DataPagerFieldCollection.Add(DataPagerField) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将指定的 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 方法将 对象添加到 NextPreviousPagerFieldDataPager 控件。
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 将添加到集合的末尾。