DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   ASP (http://www.daniweb.com/forums/forum62.html)
-   -   checkbox checkchanged event not firing in datalist control (http://www.daniweb.com/forums/thread123415.html)

SANJISH May 9th, 2008 2:49 pm
checkbox checkchanged event not firing in datalist control
 
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>&nbsp;

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


All times are GMT -4. The time now is 11:06 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC