GridViewRowEventHandler デリゲートとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > GridViewRowEventHandler デリゲートの意味・解説 

GridViewRowEventHandler デリゲート

メモ : このデリゲートは、.NET Framework version 2.0新しく追加されたものです。

GridView コントロールの RowCreated イベントと RowDataBound イベント処理するメソッド表します

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

Public Delegate Sub GridViewRowEventHandler
 ( _
    sender As Object, _
    e As GridViewRowEventArgs _
)
Dim instance As New GridViewRowEventHandler(AddressOf
 HandlerMethod)
public delegate void GridViewRowEventHandler
 (
    Object sender,
    GridViewRowEventArgs e
)
public delegate void GridViewRowEventHandler
 (
    Object^ sender, 
    GridViewRowEventArgs^ e
)
/** @delegate */
public delegate void GridViewRowEventHandler
 (
    Object sender, 
    GridViewRowEventArgs e
)
JScript では、デリゲート使用できますが、新規に宣言することはできません。

パラメータ

sender

イベントソース

e

イベント データ格納している GridViewRowEventArgs オブジェクト

解説解説

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

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

GridViewRowEventHandler デリゲート作成する場合は、イベント処理するメソッド識別してくださいイベントイベント ハンドラ関連付けるには、デリゲートインスタンスイベント追加しますデリゲート削除しない限り、そのイベント発生すると常にイベント ハンドラ呼び出されます。イベント ハンドラ デリゲート詳細については、「イベントデリゲート」を参照してください

使用例使用例

GridViewRowEventHandler デリゲートを、プログラムによって GridView コントロールRowDataBound イベント追加する方法次の例に示します

<%@ Page language="VB" %>

<script runat="server">

  Sub Page_Load(ByVal sender As
 Object, ByVal e As EventArgs)
        
    ' Create a new GridView control.
    Dim customersGridView As New
 GridView()
         
    ' Set the GridView control's properties.
    customersGridView.ID = "CustomersGridView"
    customersGridView.DataSourceID = "CustomersSqlDataSource"
    customersGridView.AutoGenerateColumns = True
    customersGridView.AllowPaging = True

    ' Programmatically register the event-handling method.
    AddHandler customersGridView.RowDataBound, AddressOf
 CustomersGridView_RowDataBound
       
    ' Add the GridView control to the Controls collection
    ' of the PlaceHolder control.
    GridViewPlaceHolder.Controls.Add(customersGridView)

  End Sub

  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>GridViewRowEventHandler Example</h3>

      <asp:placeholder id="GridViewPlaceHolder"
        runat="server"/>
            
      <!-- 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 Page_Load(Object sender, EventArgs e)
  {
        
    // Create a new GridView control.
    GridView customersGridView = new GridView();
         
    // Set the GridView control's properties.
    customersGridView.ID = "CustomersGridView";
    customersGridView.DataSourceID = "CustomersSqlDataSource";
    customersGridView.AutoGenerateColumns = true;
    customersGridView.AllowPaging = true;

    // Programmatically register the event-handling method.
    customersGridView.RowDataBound += new GridViewRowEventHandler(this.CustomersGridView_RowDataBound);
       
    // Add the GridView control to the Controls collection
    // of the PlaceHolder control.
    GridViewPlaceHolder.Controls.Add(customersGridView);

  }

  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>GridViewRowEventHandler Example</h3>

      <asp:placeholder id="GridViewPlaceHolder"
        runat="server"/>
            
      <!-- 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>

GridViewRowEventHandler デリゲートを、宣言によって GridView コントロールRowDataBound イベント追加する方法次の例に示します

<%@ 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>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Web.UI.WebControls 名前空間
GridView クラス
GridViewRowEventArgs クラス
GridView.RowCreated イベント
OnRowCreated
GridView.RowDataBound イベント
OnRowDataBound
その他の技術情報
イベントデリゲート


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

英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「GridViewRowEventHandler デリゲート」の関連用語

GridViewRowEventHandler デリゲートのお隣キーワード
検索ランキング

   

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



GridViewRowEventHandler デリゲートのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2026 GRAS Group, Inc.RSS