GridView.EnableSortingAndPagingCallbacks Propriété

Définition

Obtient ou définit une valeur indiquant si les rappels côté client sont utilisés pour les opérations de tri et de pagination.

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

Valeur de propriété

Boolean

true pour utiliser des rappels côté client pour les opérations de tri et de pagination ; sinon, false. La valeur par défaut est false.

Exceptions

La collection Columns contient une colonne qui ne prend pas en charge les rappels, tels que TemplateField.

Exemples

L’exemple suivant montre comment utiliser la EnableSortingAndPagingCallbacks propriété pour activer les rappels côté client pour les opérations de tri et de pagination.


<%@ 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>

Remarques

Par défaut, lorsqu’une opération de tri ou de pagination est effectuée, le GridView contrôle revient au serveur pour effectuer l’opération. Lorsque la EnableSortingAndPagingCallbacks propriété est définie truesur , un service est appelé sur le client pour effectuer des opérations de tri et de pagination, ce qui élimine la nécessité de publier sur le serveur.

Notes

Tous les navigateurs ne prennent pas en charge cette fonctionnalité. Pour déterminer si un navigateur prend en charge cette fonctionnalité, utilisez la SupportsCallback propriété.

Toutes les colonnes de la Columns collection doivent prendre en charge les rappels pour que cette fonctionnalité fonctionne. Si la Columns collection contient une colonne qui ne prend pas en charge les rappels, par exemple TemplateField, une NotSupportedException exception est levée.

S’applique à

Voir aussi