<%@ Page %>
Confirming Deletes in DataGrid
The web form
The Delete button
<asp:DataGrid id="DataGrid1" runat="server">
Private Sub DataGrid1_ItemDataBound
(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
Dim l As LinkButton
If e.Item.ItemType = ListItemType.Item Or
e.Item.ItemType = ListItemType.AlternatingItem Then
l = CType(e.Item.Cells(0).FindControl("cmdDel"), LinkButton)
l.Attributes.Add("onclick", "return getconfirm();")
Here we check whether the item (row) is of type Item or AlternatingItem. We then add DHTML OnClick event handler that calls a client side function getconfirm().
The getconfirm function looks like this:
if (confirm("Do you want to delete record?")==true)
I hope it was interesting. See you soon.
Bipin Joshi is an author and IT trainer who writes about apparently unrelated topics - yoga & technology! Bipin has been programming since 1995 and is working with .NET framework ever since its inception. He is an internationally published author and has authored or co-authored more than half a dozen books and numerous articles on .NET technologies. Bipin was also a Microsoft MVP for six consecutive years. Bipin conducts professional training programs helping individuals learn Microsoft technologies better and faster. You can read more about him here. To know more about his training programs go here.
Stay updated : Twitter Facebook  Google+ LinkedIn
This page is protected by copyright laws.
Copying in any form is strictly prohibited.