This documentation is archived and is not being maintained.

DataPager.PagedControlID Property

Gets or sets the ID of the control that contains the data that will be paged by the DataPager control.

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

public virtual string PagedControlID { get; set; }
<asp:DataPager PagedControlID="String" />

Property Value

Type: System.String
The ID of the control that contains the data that will be paged by the DataPager control. The default is an empty string, which indicates that this property is not set.

Use the PagedControlID property to specify the ID of the control that contains the data that will be paged by the DataPager control. The specified control must implement the IPageableItemContainer interface and must use the same naming container as the DataPager control. An example of a control that you can specify is the ListView control.

If this property is an empty string or null, the DataPager control checks whether its container control implements the IPageableItemContainer interface. For example, in the ListView control, the PagedControlID property does not have to be set if you put the DataPager control inside the ListView.LayoutTemplate template. This is because the DataPager control can automatically find the ListView control by examining the control tree.

The value of this property is stored in view state.

The following example shows how to use the PagedControlID property to dynamically associate a ListView control with a DataPager control. This code example is part of a larger example provided for the DataPager constructor.

protected void Page_Load(object sender, EventArgs e)

  // Create a new DataPager object.
  DataPager CountryDataPager = new DataPager();

  // Set the DataPager object's properties.
  CountryDataPager.PagedControlID = CountryListView.ID;
  CountryDataPager.PageSize = 15;
  CountryDataPager.Fields.Add(new NumericPagerField());

  // Add the DataPager object to the Controls collection
  // of the form.


The following example shows how to declaratively set the PagedControlID property in a DataPager control in order to page the data of a ListView control.

<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="" >
  <head id="Head1" runat="server">
    <title>DataPager PagedControlID Example</title>
    <form id="form1" runat="server">

      <h3>DataPager PagedControlID Example</h3>

      <asp:DataPager ID="DepartmentsPager" runat="server" 
          <asp:NumericPagerField />

      <asp:ListView ID="DepartmentsListView" 
          <table cellpadding="2" width="500px">
              <th>Department Name</th>
            <tr runat="server" id="itemPlaceholder"></tr>
          <tr runat="server">
              <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
              <asp:Label ID="GroupNameLabel" runat="server" Text='<%# Eval("GroupName") %>' />

      <!-- 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="DepartmentsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"            
        SelectCommand="SELECT Name, GroupName FROM HumanResources.Department" >

.NET Framework

Supported in: 4, 3.5

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.