获得Id的行图像按钮在一个内在vb.net
-
20-08-2019 - |
题
我有一个内在这窥视我创建了一个列表中的imagebuttons编程方式与addhandler如下:
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在单处理程序。我怎么找到的?
解决方案
我建议分配
imageButton.CommandName = "Delete"
imageButton.CommandArgument = Your_Row_ID_You_Want_To_Get
然后使用imageButton.空调去做你的工作。
编辑: 这里的步骤如下:
- 建立你的形象的按钮在RowCreated
- 指定名称和CommandArgument你的图像按钮在RowDataBound
- 在RowCommand检查图像按钮CommandArgument行,你应该看到的ID,你以前储存在那里。
不隶属于 StackOverflow