Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
<ThemeableAttribute(False)> _ Public Overridable Property PagedControlID As String Get Set
[ThemeableAttribute(false)] public virtual string PagedControlID { get; set; }
[ThemeableAttribute(false)] public: virtual property String^ PagedControlID { String^ get (); void set (String^ value); }
[<ThemeableAttribute(false)>] abstract PagedControlID : string with get, set [<ThemeableAttribute(false)>] override PagedControlID : string with get, set
<asp:DataPager PagedControlID="String" />
Valore proprietà
Tipo: System.StringProprietà 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.
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.
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.
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
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.
<%@ 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>
<%@ 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>
.NET Framework
Supportato in: 4, 3.5Windows 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.