GridViewSortEventArgs.SortExpression プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > GridViewSortEventArgs.SortExpression プロパティの意味・解説 

GridViewSortEventArgs.SortExpression プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

GridView コントロール内の項目の並べ替え使用する式を取得または設定します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Dim instance As GridViewSortEventArgs
Dim value As String

value = instance.SortExpression

instance.SortExpression = value
public string SortExpression { get;
 set; }
public:
property String^ SortExpression {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_SortExpression ()

/** @property */
public void set_SortExpression (String value)
public function get SortExpression
 () : String

public function set SortExpression
 (value : String)

プロパティ
GridView コントロール内の項目の並べ替え使用する式。

解説解説
使用例使用例

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>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GridViewSortEventArgs クラス
GridViewSortEventArgs メンバ
System.Web.UI.WebControls 名前空間
GridView.AllowSorting プロパティ
GridView.SortExpression プロパティ
GridViewSortEventArgs.SortDirection プロパティ


このページでは「.NET Framework クラス ライブラリ リファレンス」からGridViewSortEventArgs.SortExpression プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からGridViewSortEventArgs.SortExpression プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からGridViewSortEventArgs.SortExpression プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「GridViewSortEventArgs.SortExpression プロパティ」の関連用語

GridViewSortEventArgs.SortExpression プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



GridViewSortEventArgs.SortExpression プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS