GridViewRowEventArgs クラスとは? わかりやすく解説

GridViewRowEventArgs クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

RowCreated イベントと RowDataBound イベントデータ提供します

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

Public Class GridViewRowEventArgs
    Inherits EventArgs
Dim instance As GridViewRowEventArgs
public class GridViewRowEventArgs : EventArgs
public ref class GridViewRowEventArgs : public
 EventArgs
public class GridViewRowEventArgs extends EventArgs
public class GridViewRowEventArgs extends
 EventArgs
解説解説

GridView コントロール表示前にコントロール各行の GridViewRow オブジェクト作成する必要がありますRowCreated イベントは、GridView コントロールに行が作成されるたびに発生します。これにより、このイベント発生するたびにカスタム ルーチン (行へのカスタム コンテンツの追加など) を実行するイベント処理メソッドを提供できます

同様にコントロール各行は、GridView コントロール表示前にデータ ソースレコードバインドする必要がありますRowDataBound イベントは、(GridViewRow オブジェクトによって表される) データ行が GridView コントロールデータバインドされたときに発生します。これにより、このイベント発生するたびにカスタム ルーチン (行にバインドされたデータの値を変更するなど) を実行するイベント処理メソッドを提供できます

GridViewRowEventArgs オブジェクトイベント処理メソッド渡されることにより、イベント発生させた行プロパティアクセスできます。行の特定のセルアクセスするには、Row プロパティ格納されている GridViewRow オブジェクトCells プロパティ使用しますGridViewRow オブジェクトの RowType プロパティ使用して作成される行の種類 (ヘッダー行、データ行など) を確認できます

イベント処理詳細については、「イベント利用」を参照してください

GridViewRowEventArgsインスタンス初期プロパティ値の一覧については、GridViewSelectEventArgs コンストラクタトピック参照してください

使用例使用例

イベント処理メソッド渡されGridViewRowEventArgs オブジェクト使用してデータバインドされる行のプロパティアクセスする方法次の例に示します

<%@ Page language="VB" %>

<script runat="server">

  Sub CustomersGridView_RowDataBound(ByVal
 sender As Object, ByVal
 e As GridViewRowEventArgs)

    If e.Row.RowType = DataControlRowType.DataRow Then
    
      ' Display the company name in italics.
      e.Row.Cells(1).Text = "<i>" & e.Row.Cells(1).Text
 & "</i>"
        
    End If
    
  End Sub

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>GridView RowDataBound Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="true"
        allowpaging="true"
        onrowdatabound="CustomersGridView_RowDataBound"
 
        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="CustomersSqlDataSource"
  
        selectcommand="Select [CustomerID], [CompanyName], [Address],
 [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
            
    </form>
  </body>
</html>

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

<script runat="server">

  void CustomersGridView_RowDataBound(Object sender, GridViewRowEventArgs
 e)
  {
        
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
      // Display the company name in italics.
      e.Row.Cells[1].Text = "<i>" + e.Row.Cells[1].Text + "</i>";
        
    }
    
  }

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>GridView RowDataBound Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="true"
        allowpaging="true"
        onrowdatabound="CustomersGridView_RowDataBound" 
        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="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City],
 [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
            
    </form>
  </body>
</html>

.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.EventArgs
    System.Web.UI.WebControls.GridViewRowEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GridViewRowEventArgs メンバ
System.Web.UI.WebControls 名前空間
GridView クラス
GridViewRowEventHandler
GridView.RowCreated イベント
GridView.RowDataBound イベント
その他の技術情報
イベント利用



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

辞書ショートカット

すべての辞書の索引

「GridViewRowEventArgs クラス」の関連用語

GridViewRowEventArgs クラスのお隣キーワード
検索ランキング

   

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



GridViewRowEventArgs クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS