<%@ 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 a blogger, author, IT trainer and a Kundalini Yogi 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. He has also penned a few books on Yoga. Bipin was also a Microsoft MVP for six consecutive years. 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.