Proprietà DataPager.PagedControlID (System.Web.UI.WebControls)

Cambia visualizzazione:
ScriptFree
Riferimento a .NET Framework
Proprietà DataPager.PagedControlID
Il presente articolo è stato tradotto manualmente. Per visualizzare questa pagina e contemporaneamente visualizzarne il contenuto in lingua inglese, passare alla visualizzazione semplificata.

Ottiene o imposta la proprietà ID del controllo contenente i dati di cui il controllo DataPager eseguirà il paging.

Spazio dei nomi:  System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)
Sintassi

Visual Basic
<ThemeableAttribute(False)> _
Public Overridable Property PagedControlID As String
	Get
	Set
C#
[ThemeableAttribute(false)]
public virtual string PagedControlID { get; set; }
Visual C++
[ThemeableAttribute(false)]
public:
virtual property String^ PagedControlID {
	String^ get ();
	void set (String^ value);
}
F#
[<ThemeableAttribute(false)>]
abstract PagedControlID : string with get, set
[<ThemeableAttribute(false)>]
override PagedControlID : string with get, set
ASP.NET
<asp:DataPager PagedControlID="String" />

Valore proprietà

Tipo: System.String
Proprietà ID del controllo contenente i dati di cui il controllo DataPager eseguirà il paging. Il valore predefinito è una stringa vuota e indica che questa proprietà non è impostata.
Note

Utilizzare la proprietà PagedControlID per specificare la proprietà ID del controllo contenente i dati di cui il controllo DataPager eseguirà il paging. Il controllo specificato deve implementare l'interfaccia IPageableItemContainer e utilizzare lo stesso contenitore di denominazione del controllo DataPager. Un esempio di controllo che è possibile specificare è rappresentato da ListView.

Se la proprietà è una stringa vuota o null, il controllo DataPager verifica se il controllo contenitore implementa l'interfaccia IPageableItemContainer. Nel controllo ListView, ad esempio, non è necessario che la proprietà PagedControlID sia impostata se il controllo DataPager viene inserito all'interno del modello ListView.LayoutTemplate. Il controllo DataPager, infatti, è in grado di trovare automaticamente il controllo ListView esaminandone l’albero di controllo.

Il valore di questa proprietà è memorizzato in stato di visualizzazione.

Esempi

Nell'esempio riportato di seguito viene illustrato come utilizzare la proprietà PagedControlID per associare in modo dinamico un controllo ListView a un controllo DataPager. Questo esempio di codice fa parte di un esempio più esaustivo fornito per il costruttore DataPager.

Visual Basic

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

  ' Create a new DataPager object.
  Dim CountryDataPager As 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.
  form1.Controls.Add(CountryDataPager)

  CountryListView.DataBind()

End Sub


C#

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.
  form1.Controls.Add(CountryDataPager);

  CountryListView.DataBind();
}


Nell'esempio di codice riportato di seguito viene illustrato come impostare in modo dichiarativo la proprietà PagedControlID in un controllo DataPager per eseguire il paging dei dati di un controllo ListView.

Visual Basic

<%@ Page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head id="Head1" runat="server">
    <title>DataPager PagedControlID Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <h3>DataPager PagedControlID Example</h3>

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

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

      <!-- 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" >
      </asp:SqlDataSource>
    </form>
  </body>
</html>


C#

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head id="Head1" runat="server">
    <title>DataPager PagedControlID Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <h3>DataPager PagedControlID Example</h3>

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

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

      <!-- 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" >
      </asp:SqlDataSource>
    </form>
  </body>
</html>


Informazioni sulla versione

.NET Framework

Supportato in: 4, 3.5
Piattaforme

Windows 7, Windows Vista SP1 o versione successiva, Windows XP SP3, Windows Server 2008 (componenti di base del server non supportati), Windows Server 2008 R2 (componenti di base del server supportati con SP1 o versione successiva), Windows Server 2003 SP2

.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.
Vedere anche

Riferimenti

Altre risorse