Site Search:
Sign in | Join | Help
4Penny.net

ASP.NET

Notes, Tricks and Tips on ASP.NET Coding

How to Confirm Deletion in a gridview

This code will confirm that you want to delete a row in a gridview:

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

Dim lnkDelete As LinkButton

If e.Row.RowType = DataControlRowType.DataRow Then

lnkDelete = CType(e.Row.FindControl("lnkDelete"), LinkButton)

Dim strUserName As String

strUserName = DataBinder.Eval(e.Row.DataItem, "vchrUserName")

lnkDelete.Attributes.Add("onclick", "BLOCKED SCRIPTreturn confirm('Are you sure you want to delete user " + Chr(34) + strUserName + Chr(34) + "')")

End If

End Sub

Published Feb 08 2007, 09:59 AM by Steve Gray
Filed under:

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.