GridViewのテンプレートフィールドに行番号割当
概要
GridViewのテンプレートフィールドにbuttonコントロール配置した際に
button毎に行番号を割り振る。
button毎に行番号を割り振る。
'GridViewの行追加時に実行される
Protected Sub GridView1_RowCreated1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Then
'イベントからテンプレートフィールドに配置されたボタンを取得
Dim cmdEdit As Button = CType(e.Row.FindControl("cmdEdit"), Button)
'ボタンに行情報を配置
cmdEdit.CommandArgument = e.Row.RowIndex.ToString
End If
End Sub