0

我有一个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

我的问题是在单击处理程序中获取单击的图像按钮行的值。我怎么得到那个?

4

1 回答 1

3

我建议分配

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

然后使用 imageButton.OnCommand 完成您的工作。

编辑: 以下是要遵循的步骤:

  1. 在 RowCreated 中创建图像按钮
  2. 在 RowDataBound 中分配图像按钮的 CommandName 和 CommandArgument
  3. 在 RowCommand 中,检查该行的图像按钮 CommandArgument,您应该会看到之前存储在那里的 ID。
于 2009-05-08T15:16:52.883 回答