Notes, Tricks and Tips on ASP.NET Coding
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
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.