restinpiece @ ウィキ

GridViewのテンプレートフィールドに行番号割当

最終更新:

restinpiece

- view
メンバー限定 登録/ログイン

GridViewのテンプレートフィールドに行番号割当


概要

GridViewのテンプレートフィールドに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
 
人気記事ランキング
目安箱バナー