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 イベント
その他の技術情報
イベントの利用

GridViewRowEventArgs コンストラクタ

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

GridViewRowEventArgs クラスの新しいインスタンスを初期化します。

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

Public Sub New ( _
    row As GridViewRow _
)
Dim row As GridViewRow

Dim instance As New GridViewRowEventArgs(row)
public GridViewRowEventArgs (
    GridViewRow row
)
public:
GridViewRowEventArgs (
    GridViewRow^ row
)
public GridViewRowEventArgs (
    GridViewRow row
)
public function GridViewRowEventArgs (
    row : GridViewRow
)

パラメータ

row

作成される行またはデータにバインドされる行を表す GridViewRow オブジェクト。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GridViewRowEventArgs クラス
GridViewRowEventArgs メンバ
System.Web.UI.WebControls 名前空間
Row

GridViewRowEventArgs プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Row 作成される行またはデータにバインドされる行を取得します。
参照参照

関連項目

GridViewRowEventArgs クラス
System.Web.UI.WebControls 名前空間
GridView クラス
GridViewRowEventHandler
GridView.RowCreated イベント
GridView.RowDataBound イベント

その他の技術情報

イベントの利用

GridViewRowEventArgs メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

GridViewRowEventArgs クラス
System.Web.UI.WebControls 名前空間
GridView クラス
GridViewRowEventHandler
GridView.RowCreated イベント
GridView.RowDataBound イベント

その他の技術情報

イベントの利用

GridViewRowEventArgs メンバ

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

GridViewRowEventArgs データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド GridViewRowEventArgs GridViewRowEventArgs クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Row 作成される行またはデータにバインドされる行を取得します。
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

GridViewRowEventArgs クラス
System.Web.UI.WebControls 名前空間
GridView クラス
GridViewRowEventHandler
GridView.RowCreated イベント
GridView.RowDataBound イベント

その他の技術情報

イベントの利用



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「GridViewRowEventArgs」の関連用語

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

   

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



GridViewRowEventArgsのページの著作権

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

©2026 GRAS Group, Inc.RSS