I have a checkbox that is part of a repeater. I'm trying to get the checkbox's checkedchanged event to occur when I check the box and when I uncheck the box. The event currently only triggers when I check the box however… not when i uncheck also. I'll post some code below and hopefully someone can steer me in the right direction. Thanks!
Adding Handler to Repeater CheckBox Control
Dim MyCheckBox As New CheckBox
MyCheckBox = e.Item.FindControl("MyCheckBox")
AddHandler MyCheckBox.CheckedChanged, AddressOf MyCheckBox_CheckedChanged
My CheckedChanged Handler Event
Private Sub MyCheckBox_CheckedChanged(sender As Object, e As System.EventArgs)
Dim RepeaterItem As RepeaterItem
For Each RepeaterItem In MyRepeater.Items
If IsListItem(RepeaterItem) Then
If CType(sender, CheckBox).Checked Then
CType(RepeaterItem.FindControl("SelectionCheckBox"), CheckBox).Checked = True
Else
CType(RepeaterItem.FindControl("SelectionCheckBox"), CheckBox).Checked = False
End If
End If
Next
End Sub
ASPX File Check Box Declaration
<asp:CheckBox ID="MyCheckBox" AutoPostBack="True" Text="" runat="server" />
Best Answer
Do you have AutoPostBack = true set up in your ASPX file.