Condividi tramite


GridView.EnableSortingAndPagingCallbacks Proprietà

Definizione

Ottiene o imposta un valore che indica se i callback sul lato client vengono utilizzati per le operazioni di ordinamento e paging.

public:
 virtual property bool EnableSortingAndPagingCallbacks { bool get(); void set(bool value); };
public virtual bool EnableSortingAndPagingCallbacks { get; set; }
member this.EnableSortingAndPagingCallbacks : bool with get, set
Public Overridable Property EnableSortingAndPagingCallbacks As Boolean

Valore della proprietà

true per utilizzare callback lato client per operazioni di ordinamento e paging; in caso contrario, false. Il valore predefinito è false.

Eccezioni

La Columns raccolta contiene una colonna che non supporta i callback, ad esempio TemplateField.

Esempio

Nell'esempio seguente viene illustrato come usare la EnableSortingAndPagingCallbacks proprietà per abilitare i callback lato client per le operazioni di ordinamento e paging.


<%@ 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 runat="server">
    <title>GridView EnableSortingAndPagingCallbacks Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView EnableSortingAndPagingCallbacks Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        allowpaging="true"
        allowsorting="true"
        enablesortingandpagingcallbacks="true"        
        runat="server">
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="CustomersSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
        
    </form>
  </body>
</html>

<%@ 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 runat="server">
    <title>GridView EnableSortingAndPagingCallbacks Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView EnableSortingAndPagingCallbacks Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        allowpaging="true"
        allowsorting="true"
        enablesortingandpagingcallbacks="true"        
        runat="server">
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="CustomersSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
        
    </form>
  </body>
</html>

Commenti

Per impostazione predefinita, quando viene eseguita un'operazione di ordinamento o paging, il controllo esegue il GridView postback al server per eseguire l'operazione. Quando la EnableSortingAndPagingCallbacks proprietà è impostata su true, viene chiamato un servizio sul client per eseguire operazioni di ordinamento e paging, eliminando la necessità di eseguire il postback al server.

Annotazioni

Non tutti i browser supportano questa funzionalità. Per determinare se un browser supporta questa funzionalità, utilizzare la SupportsCallback proprietà .

Per il funzionamento di questa funzionalità, tutte le colonne della Columns raccolta devono supportare i callback. Se la Columns raccolta contiene una colonna che non supporta i callback, ad esempio TemplateField, viene generata un'eccezione NotSupportedException .

Si applica a

Vedi anche