troubleshooting Question

disable all checkboxes inside a nested datalist control when one checkbox inside the datalist is clicked

Avatar of TrialUser
TrialUserFlag for Afghanistan asked on
C#ASP.NETVisual Basic.NET
4 Comments1 Solution980 ViewsLast Modified:
I have a datalistparent and a datalistchild . Inside the datalistchild itemtemplate, I have checkboxes. When the user clicks on a checkbox then all checkboxes inside that datalistchild should be disabled. all in server side code. I have attached the html and .vb code. Please help. Thanks

 Protected Sub Value_Clicked(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim chk As CheckBox = DirectCast(sender, CheckBox)
        Dim intValueID As Integer = DirectCast(chk.Parent.FindControl("lblAttributeValueID"), Label).Text
        Dim intNameID As Integer = DirectCast(chk.Parent.FindControl("lblAttrNameID"), Label).Text
        If chk.Checked Then
            AddNavigationProductFilter(intNameID, intValueID, True)
            'here diable all checkboxes in this particular item template (dlAttributeValues)
            AddNavigationProductFilter(intNameID, intValueID, False)
            'here enable all checkboxes in this particular item template (dlAttributeValues)
        End If
    End Sub

    <div class="Attributes">
<asp:DataList ID="dlAttributes" runat="server" RepeatDirection="Horizontal" RepeatColumns="3" Width="100%">
<ItemStyle Width="33.3%"/>
    <asp:Label ID="lblAttributeNameID" runat="server" Visible = "false" Text='<%# DataBinder.Eval(Container.DataItem, "ID")%>'></asp:Label>
        <span style="color:#58595B;font-size:14px;font-weight:bold;"><%# DataBinder.Eval(Container.DataItem, "ShortName")%></span>    
        <div style="height:100px;overflow:auto; border: 1px solid #CACACA;margin:10px 10px 10px 0px;padding:10px;">
           <asp:DataList ID="dlAttributeValues" runat="server">
                    <asp:Label ID="lblAttrNameID" runat="server" Visible = "false" Text='<%# DataBinder.Eval(Container.DataItem, "AttributeNameID")%>'></asp:Label>
                    <asp:Label ID="lblAttributeValueID" runat="server" Visible = "false" Text='<%# DataBinder.Eval(Container.DataItem, "AttributeValueID")%>'></asp:Label>
                    <asp:checkbox ID="chkValue" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"AttributeValue")%>' AutoPostBack="true" OnCheckedChanged="Value_Clicked"/>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros