我有一个包含UpdatePanel和5个GridView的页面。我在Gridview外部有一个删除按钮,允许快速删除多个文件。是否可以对所有Gridview使用一个删除按钮单击事件?
Protected Sub deletePacketBtn_Click(sender As Object, e As EventArgs) Handles deletePacketBtn.Click
'Loop through all the rows in gridview
For Each gvrow As C1GridViewRow In packetGrid.Rows
'Finiding checkbox control in gridview for particular row
Dim chkdelete As CheckBox = CType(gvrow.FindControl("chkDelete"), CheckBox)
'Condition to check checkbox selected or not
If chkdelete.Checked Then
'Getting ID of particular row using datakey value
Dim fileID As Integer = Convert.ToInt32(packetGrid.DataKeys(gvrow.RowIndex).Value)
PacketDataSource.DeleteParameters("original_PKT_Key").DefaultValue = fileID.ToString
PacketDataSource.Delete()
End If
Next
packetGrid.DataBind()
End Sub
答案 0 :(得分:0)
是的, sender
是导致删除事件的GridView
。
如果您只是将sender
转换为GridView(不知道正确的VB语法,抱歉),您就会知道哪一个导致了该事件。< /击>
以上代码仅适用于GridView的Delete事件,而不适用于按钮单击。