check\uncheck all checkboxes in datalist control in asp.net with vb.
Protected Sub DataList8_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList8.ItemDataBound
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim chkSelect As New CheckBox
chkSelect = DirectCast(e.Item.FindControl("chkSelect"), CheckBox)
chkSelect.Attributes.Add("onclick", "javascript:return Validate(this.name)")
End If
end sub
getting error in chkSelect.Attributes.Add("onclick", "javascript:return Validate(this.name)")
Object reference not set to an instance of an object.
give me the suggesion where i have to update my code