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

chkselect check box doesnt exists,so u are getting the error.Whats directcast

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.