質問

gridviewがあり、そのgridviewで、次のようにaddhandlerを使用してプログラムでimagebuttonsのリストを作成しました。

Dim deletecshr As New ImageButton
deletecshr.ImageUrl = "\images\bttnDeletemini.gif"
deletecshr.ToolTip = "This Will Delete All Cashiers"
AddHandler deletecshr.Click, AddressOf deletecshr_Click
deletecshr.Attributes.Add("onclick", "javascript: if(confirm('Are you sure you want to delete all of these cashiers?')==false) return false;")

    If e.Row.Cells.Count > 2 And e.Row.RowType <> DataControlRowType.Header And e.Row.RowType <> DataControlRowType.Footer Then
        e.Row.Cells(3).Controls.Add(deletecshr)
    End If

私の問題は、クリックハンドラーでクリックされた画像ボタンの行の値を取得することです。どうすれば入手できますか?

役に立ちましたか?

解決

割り当てることをお勧めします

imageButton.CommandName = "Delete"
imageButton.CommandArgument = Your_Row_ID_You_Want_To_Get

そしてimageButton.OnCommandを使用して作業を行います。

編集:   手順は次のとおりです。

  1. RowCreatedで画像ボタンを作成
  2. RowDataBoundで画像ボタンのCommandNameとCommandArgumentを割り当てます
  3. RowCommandで、その行のイメージボタンCommandArgumentを確認すると、以前にそこに保存したIDが表示されます。
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top