After binding the repeater control, my check box looks like the below,
I have two doubts here:
If I select checkbox of Group 1, all the items under group 1 should be selected. How can I do this ?
And I have "Select ALL" button which when clicked should select all the items of all groups. Since the checkbox is inside the repeater control, I'm not sure how to handle it.
Group 1
Item 1
Item 2
Group 2
Item 3
Item 4
Group 3
Item 5
Item 6
ASPX :
<ol>
<asp:Repeater ID="rp_Groups" runat="server" OnItemDataBound="rp_Groups_ItemDataBound">
<ItemTemplate>
<ul>
<asp:CheckBox RepeatColumns="2" runat="server" ID="chk_Group" Text='<%# Eval("category_type") %>' Value='<%# Eval("service_type_category_id") %>' onclick="OnGroupClick" />
<asp:CheckBoxList runat="server" ID="chkServiceType" style="padding-left:20px" DataValueField="ServiceTypeID" DataTextField="Name" EnableViewState="true"
></asp:CheckBoxList>
<br />
</ul>
</ItemTemplate>
</asp:Repeater>
</ol>
<script type="text/javascript">
function OnGroupClick(group) {
for(item in group.getElementsByTagName('input')) {
item.checked = group.checked;
}
}
function selectAll() {
$("#<%=chkServiceType.ClientID %> input[type=checkbox]").each(function () {
this.checked = true;
})
}
</script>