Riferimento a .NET Framework
Costruttore DataPager
Il presente articolo è stato tradotto manualmente. Per visualizzare questa pagina e contemporaneamente visualizzarne il contenuto in lingua inglese, passare alla visualizzazione semplificata.
Inizializza una nuova istanza della classe DataPager.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
Sintassi
Visual Basic
Public Sub New
C#
public DataPager()
Visual C++
public:
DataPager()
F#
new : unit -> DataPager
Note
Per aggiungere in modo dinamico un controllo DataPager a una pagina, creare un nuovo oggetto DataPager. Impostare le relative proprietà, quindi aggiungerlo all'insieme Controls di un controllo contenitore, ad esempio un controllo PlaceHolder.
Esempi
Nell'esempio riportato di seguito viene illustrato come utilizzare il costruttore per aggiungere in modo dinamico un controllo DataPager a una pagina.
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"> <script runat="server"> 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 </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>DataPager Constructor Example</title> </head> <body> <form id="form1" runat="server"> <h3>DataPager Constructor Example</h3> <asp:ListView ID="CountryListView" DataSourceID="CountryDataSource" runat="server"> <LayoutTemplate> <ul runat="server" id="CountryList"> <li runat="server" id="itemPlaceholder"></li> </ul> </LayoutTemplate> <ItemTemplate> <li runat="server"> <asp:Label runat="server" ID="CountryLabel" Text='<%# Eval("CountryRegionCode") & " - " & Eval("Name") %>' /> </li> </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="CountryDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>" SelectCommand="SELECT [CountryRegionCode], [Name] FROM [Person].[CountryRegion]"> </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"> <script runat="server"> 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(); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>DataPager Constructor Example</title> </head> <body> <form id="form1" runat="server"> <h3>DataPager Constructor Example</h3> <asp:ListView ID="CountryListView" DataSourceID="CountryDataSource" runat="server"> <LayoutTemplate> <ul runat="server" id="CountryList"> <li runat="server" id="itemPlaceholder"></li> </ul> </LayoutTemplate> <ItemTemplate> <li runat="server"> <asp:Label runat="server" ID="CountryLabel" Text='<%# Eval("CountryRegionCode") + " - " + Eval("Name") %>' /> </li> </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="CountryDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>" SelectCommand="SELECT [CountryRegionCode], [Name] FROM [Person].[CountryRegion]"> </asp:SqlDataSource> </form> </body> </html>
Informazioni sulla versione
.NET Framework
Supportato in: 4, 3.5Piattaforme
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