Ottiene o imposta il nome del campo della stringa di query.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
Public Property QueryStringField As String Get Set
public string QueryStringField { get; set; }
public: property String^ QueryStringField { String^ get (); void set (String^ value); }
member QueryStringField : string with get, set
<asp:DataPager QueryStringField="String" />
Valore proprietà
Tipo: System.StringNome del campo della stringa di query. L'impostazione predefinita è una stringa vuota che indica che il controllo DataPager utilizzerà un comando HTTP POST per spostarsi tra le pagine.
Utilizzare la proprietà QueryStringField per specificare che il controllo DataPager utilizza un commando HTTP GET per spostarsi tra le pagine. Nelle richieste GET un campo della stringa di query costituito da una coppia nome/valore viene aggiunto all'URL della pagina. Il nome viene impostato utilizzando la proprietà QueryStringField. Il valore è il numero di pagina corrispondente. Se QueryStringField è una stringa vuota o null, il controllo utilizza un comando HTTP POST per spostarsi tra le pagine.
L'impostazione di questa proprietà risulta utile se si desidera far indicizzare tutte le pagine di dati da un motore di ricerca. Ciò accade in quanto il controllo produce un URL diverso per ogni pagina di dati.
Quando si imposta la proprietà QueryStringField, è possibile che siano valide le condizioni seguenti:
-
Una pagina include più controlli DataPager ed essi fanno riferimento allo stesso controllo con associazione a dati. In tal caso, verificare che la proprietà QueryStringField di tali controlli DataPager sia impostata sullo stesso valore.
-
Una pagina include più controlli DataPager ed essi fanno riferimento a diversi controlli con associazione a dati. In tal caso, verificare che la proprietà QueryStringField di tali controlli DataPager sia impostata su valori diversi. Se i controlli DataPager vengono impostati sullo stesso valore, i controlli con associazione a dati associati verranno sottoposti a paging contemporaneamente in quanto utilizzeranno lo stesso campo della stringa di query.
Se non si seguono le linee guida precedenti, potrebbe verificarsi un comportamento di paging imprevisto. Tuttavia, il controllo non genererà alcuna eccezione.
Se la proprietà QueryStringField non è una stringa vuota o null, il valore della proprietà ButtonType degli oggetti NumericPagerField o NextPreviousPagerField verrà ignorato. In tal caso, gli oggetti utilizzano il controllo HyperLink per creare i relativi pulsanti per lo spostamento.
Nell'esempio di codice riportato di seguito viene illustrato come impostare in modo dichiarativo la proprietà QueryStringField in un controllo DataPager per spostarsi tra le pagine utilizzando una stringa di query. In questo esempio vengono illustrati due controlli DataPager utilizzati per spostarsi tra le pagine di dati visualizzati da un solo 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 Example</title> <style type="text/css"> th { background-color:#eef4fa; border-top:solid 1px #9dbbcc; border-bottom:solid 1px #9dbbcc; } </style> </head> <body> <form id="form1" runat="server"> <h3>DataPager QueryStringField Example</h3> <asp:DataPager runat="server" ID="DataPager1" PagedControlID="CountriesListView" QueryStringField="pageNumber"> <Fields> <asp:NumericPagerField /> </Fields> </asp:DataPager> <br /><br /> <asp:ListView ID="CountriesListView" DataSourceID="CountryDataSource" runat="server" > <LayoutTemplate> <table cellpadding="4" width="500" runat="server" id="tblCountries"> <tr runat="server"> <th runat="server">Code</th> <th runat="server">Name</th> </tr> <tr runat="server" id="itemPlaceholder" /> </table> </LayoutTemplate> <ItemTemplate> <tr> <td> <asp:Label ID="CountryCodeLabel" runat="server" Text='<%# Eval("CountryRegionCode")%>' /> </td> <td> <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name")%>' /> </td> </tr> </ItemTemplate> </asp:ListView> <br /> <!-- The second DataPager control. --> <asp:DataPager runat="server" ID="DataPager2" PagedControlID="CountriesListView" QueryStringField="pageNumber"> <Fields> <asp:NumericPagerField /> </Fields> </asp:DataPager> <!-- 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>
<%@ 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 Example</title> <style type="text/css"> th { background-color:#eef4fa; border-top:solid 1px #9dbbcc; border-bottom:solid 1px #9dbbcc; } </style> </head> <body> <form id="form1" runat="server"> <h3>DataPager QueryStringField Example</h3> <asp:DataPager runat="server" ID="DataPager1" PagedControlID="CountriesListView" QueryStringField="pageNumber"> <Fields> <asp:NumericPagerField /> </Fields> </asp:DataPager> <br /><br /> <asp:ListView ID="CountriesListView" DataSourceID="CountryDataSource" runat="server" > <LayoutTemplate> <table cellpadding="4" width="500" runat="server" id="tblCountries"> <tr runat="server"> <th runat="server">Code</th> <th runat="server">Name</th> </tr> <tr runat="server" id="itemPlaceholder" /> </table> </LayoutTemplate> <ItemTemplate> <tr> <td> <asp:Label ID="CountryCodeLabel" runat="server" Text='<%# Eval("CountryRegionCode")%>' /> </td> <td> <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name")%>' /> </td> </tr> </ItemTemplate> </asp:ListView> <br /> <!-- The second DataPager control. --> <asp:DataPager runat="server" ID="DataPager2" PagedControlID="CountriesListView" QueryStringField="pageNumber"> <Fields> <asp:NumericPagerField /> </Fields> </asp:DataPager> <!-- 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>
.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.