This article was translated by machine. To view in the article in English, select the English check box. You can also display the English text in a popup window by moving the mouse pointer over the text.
This documentation is archived and is not being maintained.

GridViewSortEventArgs.SortDirection الخاصية

Visual Studio 2010

GridView أسلوب تجاوزات لفئة أسلوب الفئة إلى دوماً بإرجاع .

مساحة الاسم:  System.Web.UI.WebControls
التجميع:  System.Web (في System.Web.dll)

public SortDirection SortDirection { get; set; }

قيمة الخاصية

النوع: System.Web.UI.WebControls.SortDirection
واحد of the SortDirection قيم.

When the Sorting event is raised, you can use the SortDirection property to determine the order in which the GridView control will sort its items (based on the sort expression) when the sort operation is performed. تعيين Sortingعنصر التحكم الداخلي نص.SortDirection

The following example demonstrates how to use the SortDirection property to determine the direction in which to sort a GridView control. الكائن الذي تم إدخاله هو XML غير منسق بشكل جيد.

<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<script runat="server">

  void CustomersGridView_Sorting(Object sender, GridViewSortEventArgs e)
    // By default, the sort order toggles when the user clicks 
    // the same sort button repeatedly. For this example, cancel
    // the sort operation if the user attempts to sort in descending
    // order.
    if (e.SortDirection == SortDirection.Descending)
      e.Cancel = true;
      Message.Text = "Sorting in descending order is not supported.";
      Message.Text = "";


<html xmlns="" >
  <head runat="server">
    <title>GridViewSortEventArgs SortDirection Example</title>
    <form id="form1" runat="server">

      <h3>GridViewSortEventArgs SortDirection Example</h3>

      <asp:label id="Message"


      <asp:gridview id="CustomersGridView" 
        emptydatatext="No data available." 


      <!-- 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%>" 


نظام التشغيل Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, الإصدار x64 من نظام التشغيل Windows XP Professional, Windows XP Starter Edition, Windows Server 2008, نظام التشغيل Windows Server 2003, نظام التشغيل Windows Server 2000 المزود بحزمة الخدمة SP4, نظام التشغيل Windows Millennium Edition, نظام التشغيل Windows 98

لا يدعم .NET Framework و .NET Compact Framework كافة الإصدارات الخاصة بكل نظام أساسي. للحصول على قائمة بالإصدارات المدعمة، راجع متطلبات النظام إطار عمل .NET.

.NET Framework

مدعوم في: 4, 3.5, 3.0, 2.0