I have a checkbox inside a datalist control with Autopostback="True". When a user clicks the checkbox the associated event Handler is not firing.
My code is
In HTML :
<asp:DataList ID="myDataList" runat="server" RepeatColumns="1" RepeatDirection="Vertical" >
<ItemTemplate>
<asp:CheckBox ID="chkid" runat="server" autopostback="True" />
<%#"Id " + Container.DataItem("CustomerID")%><br />
<%#"Name " + Container.DataItem("ContactName")%>
<br />
<br />
</ItemTemplate>
</asp:DataList>
In Code behind :
Protected Sub myDataList_ItemCreated(ByVal sender As Object, ByVal e As system.Web.UI.WebControls.DataListItemEventArgs) Handles myDataList.ItemCreated
Dim alSelectedValues As New ArrayList
For Each item As DataListItem In myDataList.Items
'check the item isn't a header or footer
If e.Item.ItemIndex > -1 Then
Dim cb As CheckBox = e.Item.FindControl("chkid")
AddHandler cb.CheckedChanged, AddressOf Me.checkboxclicked
Dim value As String = cb.Text
Dim checked As Boolean = cb.Checked
If checked Then
alSelectedValues.Add(value)
End If
End If
Next
The checkboxclicked event Handler is not firing
Please help
Regards
Sanjish