0 Replies - 1601 Views - Last Post: 13 August 2013 - 04:25 AM Rate Topic: -----

#1 asp_newbie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-August 13

ASP Nested Reepater Problem

Posted 13 August 2013 - 04:25 AM

Good afternoon folks,
I am new to ASP and also to this forum, so hopefully I'm posting this request in the correct section.

I want to be able to click on the parent checkBox in my nested repeater which will then check all the child check boxes within that group.
Currently, when I click on a group header it checks all the child boxes in all groups.
I would be very grateful for any advice you could offer.

Many thanks in advance

My output should look something like this (Groceries and Cereals being the groups in this example):

[ ] Groceries
[ ] Apples
[x] Bananas
[x] Strawberries

[x] Rice Krispies
[x] Corn Flakes
[X] Bran Flakes

My markup looks like this:
    <div id="Content" style="height:800px; text-align:left;">
        <table style="width:800px; margin:10px auto;">
            <asp:Repeater ID="r" runat="server">
                        <td><br /> </td>
                        <asp:CheckBox id="parent" Text='<%# Container.DataItem("ParentData")%>' runat="server" onclick="checkAll(this)" />                                                  
                        <asp:CheckBoxList ID="child" runat="server" DataSource='<%# Container.DataItem.CreateChildView("ChildData") %>'
                         DataValueField="UniqueID" DataTextField="ItemCaption" />
        <asp:Button id="btnSubmit" Text=" Transfer " runat="server" onclick="SubmitStuff"/>

and I have a js function like this:

<script type="text/javascript">
    function checkAll(cb) {
        var ctrls = document.getElementsByTagName('input');
        for (var i = 0; i < ctrls.length; i++) {
            var cbox = ctrls[i];
            if (cbox.type == "checkbox") {
                cbox.checked = cb.checked;

This post has been edited by modi123_1: 13 August 2013 - 05:38 AM
Reason for edit:: please use code tags

Is This A Good Question/Topic? 0
  • +

Page 1 of 1