Looking for a CheckBoxList(DataBinded) in a DataList sample on the NET

  • Thread starter Patrick Olurotimi Ige
  • Start date

P

Patrick Olurotimi Ige

I have a CheckBoxList(which is Databinded) in a Datalist.
My DataBinded is done in the onItemDataBound

I'm using this method below to select the selected item in a DataBinded
CheckBoxList.

Everything works fine but when i tick a checkbox i get the error at
line:-
For i = 0 To checkboxlist1.Items.Count - 1
Object reference not set to an instance of an object.

Looking for sample or resources related.
Thanks


<asp:checkboxlist OnSelectedIndexChanged="chk_SelectedIndexChanged"
id="checkboxlist1" Runat="server" AutoPostBack="True"
</asp:checkboxlist></td>


Public Sub chk_SelectedIndexChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles checkboxlist1.SelectedIndexChanged
Dim i As Integer
For i = 0 To checkboxlist1.Items.Count - 1
If checkboxlist1.Items(i).Selected Then
Message.Text = Message.Text & checkboxlist1.Items(i).Selected &
"<br>"
Else
Message.Text = Message.Text & "false <br>"
End If
Next
End Sub
 
Ad

Advertisements


Top