ietprofessional
Programmer
Hi Everyone,
I have a datalist with an edit and delete button and both of them worked fine, until I wanted to put a message box confirmation for the delete button.
Now when I click the Edit button I'm getting this error on the lnkDelete.Attributes.Add... line:
Object reference not set to an instance of an object.
By the way, the delete button works fine.
Thanks!
I have a datalist with an edit and delete button and both of them worked fine, until I wanted to put a message box confirmation for the delete button.
Now when I click the Edit button I'm getting this error on the lnkDelete.Attributes.Add... line:
Object reference not set to an instance of an object.
Code:
Private Sub dlAcc_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlAcc.ItemDataBound
If Not e.Item.ItemType = ListItemType.Header And Not e.Item.ItemType = ListItemType.Footer Then
Dim lnkDelete As Button = CType(e.Item.FindControl("btnDelete"), Button)
lnkDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this record?');")
End If
End Sub
By the way, the delete button works fine.
Thanks!