GridView.EnableSortingAndPagingCallbacks Proprietà

Definizione

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

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à

Boolean

true per utilizzare callback sul lato client per le operazioni di ordinamento e di spostamento, altrimenti false. Il valore predefinito è false.

Eccezioni

L'insieme Columns 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 GridView controllo esegue nuovamente il post 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, che elimina la necessità di eseguire il postback al server.

Nota

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

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

Si applica a

Vedi anche