GridViewSortEventArgs.SortExpression プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As GridViewSortEventArgs Dim value As String value = instance.SortExpression instance.SortExpression = value
/** @property */ public String get_SortExpression () /** @property */ public void set_SortExpression (String value)
GridView コントロール内の項目の並べ替えに使用する式。

Sorting イベントが発生した場合に、SortExpression プロパティを使用して、並べ替え操作の実行時に GridView コントロールの並べ替えに使用される並べ替え式を確認できます。既定では、GridView コントロールは一度に 1 つの列を並べ替えます。並べ替え式には、単に並べ替えるフィールドの名前が含まれます。プログラムによってこのプロパティにフィールド名のコンマ区切りリストを設定して、一度に複数の列を並べ替えることもできます。

SortExpression プロパティを使用して、並べ替えを行う GridView コントロール内の列を確認する方法を次の例に示します。ユーザーがアドレス列を並べ替えようとすると、並べ替え操作がキャンセルされます。
<%@ Page language="VB" %> <script runat="server"> Sub CustomersGridView_Sorting(sender As Object, e As GridViewSortEventArgs) ' Cancel the sorting operation if the user attempts ' to sort by address. If e.SortExpression = "Address" Then e.Cancel = True Message.Text = "You cannot sort by address." SortInformationLabel.Text = "" Else Message.Text = "" End If End Sub Sub CustomersGridView_Sorted(ByVal sender As Object, ByVal e As EventArgs) ' Display the sort expression and sort direction. SortInformationLabel.Text = "Sorting by " & _ CustomersGridView.SortExpression.ToString() & _ " in " & CustomersGridView.SortDirection.ToString() & _ " order." End Sub </script> <html> <body> <form runat="server"> <h3>GridView Sorted and Sorting Example</h3> <asp:label id="Message" forecolor="Red" runat="server"/> <br/> <asp:label id="SortInformationLabel" forecolor="Navy" runat="server"/> <br/> <asp:gridview id="CustomersGridView" datasourceid="CustomersSource" autogeneratecolumns="true" allowpaging="true" emptydatatext="No data available." allowsorting="true" onsorting="CustomersGridView_Sorting" onsorted="CustomersGridView_Sorted" 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="C#" %> <script runat="server"> void CustomersGridView_Sorting(Object sender, GridViewSortEventArgs e) { // Cancel the sorting operation if the user attempts // to sort by address. if (e.SortExpression == "Address") { e.Cancel = true; Message.Text = "You cannot sort by address."; SortInformationLabel.Text = ""; } else { Message.Text = ""; } } void CustomersGridView_Sorted(Object sender, EventArgs e) { // Display the sort expression and sort direction. SortInformationLabel.Text = "Sorting by " + CustomersGridView.SortExpression.ToString() + " in " + CustomersGridView.SortDirection.ToString() + " order."; } </script> <html> <body> <form runat="server"> <h3>GridView Sorting Example</h3> <asp:label id="Message" forecolor="Red" runat="server"/> <br/> <asp:label id="SortInformationLabel" forecolor="Navy" runat="server"/> <br/> <asp:gridview id="CustomersGridView" datasourceid="CustomersSource" autogeneratecolumns="true" allowpaging="true" emptydatatext="No data available." allowsorting="true" onsorting="CustomersGridView_Sorting" onsorted="CustomersGridView_Sorted" 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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からGridViewSortEventArgs.SortExpression プロパティを検索する場合は、下記のリンクをクリックしてください。

- GridViewSortEventArgs.SortExpression プロパティのページへのリンク