GridViewSortEventArgs.SortDirection Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Denetimin sıralandığı GridView yönü alır veya ayarlar.
public:
property System::Web::UI::WebControls::SortDirection SortDirection { System::Web::UI::WebControls::SortDirection get(); void set(System::Web::UI::WebControls::SortDirection value); };
public System.Web.UI.WebControls.SortDirection SortDirection { get; set; }
member this.SortDirection : System.Web.UI.WebControls.SortDirection with get, set
Public Property SortDirection As SortDirection
Özellik Değeri
Değerlerden SortDirection biri.
Örnekler
Aşağıdaki örnek, bir denetimi sıralama SortDirection yönünü GridView belirlemek için özelliğinin nasıl kullanılacağını gösterir. Kullanıcı azalan düzende sıralamayı denerse sıralama işlemi iptal edilir.
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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.";
}
else
{
Message.Text = "";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>GridViewSortEventArgs SortDirection Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>GridViewSortEventArgs SortDirection Example</h3>
<asp:label id="Message"
forecolor="Red"
runat="server"/>
<br/>
<asp:gridview id="CustomersGridView"
datasourceid="CustomersSource"
autogeneratecolumns="true"
allowpaging="true"
emptydatatext="No data available."
allowsorting="true"
onsorting="CustomersGridView_Sorting"
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">
<script runat="server">
Sub CustomersGridView_Sorting(ByVal sender As Object, ByVal e As GridViewSortEventArgs)
' 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 Then
e.Cancel = True
Message.Text = "Sorting in descending order is not supported."
Else
Message.Text = ""
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>GridViewSortEventArgs SortDirection Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>GridViewSortEventArgs SortDirection Example</h3>
<asp:label id="Message"
forecolor="Red"
runat="server"/>
<br/>
<asp:gridview id="CustomersGridView"
datasourceid="CustomersSource"
autogeneratecolumns="true"
allowpaging="true"
emptydatatext="No data available."
allowsorting="true"
onsorting="CustomersGridView_Sorting"
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>
Açıklamalar
Sorting Olay tetiklendiğinde, sıralama işlemi gerçekleştirildiğinde denetimin öğelerini sıralama sırasını GridView (sıralama ifadesine göre) belirlemek için özelliğini kullanabilirsinizSortDirection. Sorting Olay sıralama işleminden önce gerçekleştiğinden, sıralama yönünü program aracılığıyla ayarlamak için özelliğini de kullanabilirsinizSortDirection.
Şunlara uygulanır
Ayrıca bkz.
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin