Adding a Confirmation message box to a delete command button in a Datagrid column before deleting from a table in a database
CODE:
Private Sub dgView_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgView.ItemDataBound
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem
Dim deleteButton As LinkButton = CType(e.Item.Cells(6).Controls(0), LinkButton)
deleteButton.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to delete this ?');")
End Select
End Sub
Private Sub dgView_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgView.DeleteCommand
If e.CommandName = "Delete" Then
'delete from database commands
BindData()
End If
End Sub
0 comments:
Post a Comment