Can you please help me.
I have an ASP RadioButtonList with two list items; Select All and UnSelect All.
Radio Button List to select all or unselect all
I also have an ASP CheckBoxList that is database bound. I need to check all items on the check box when the Select All button is selected and unselect all if the Unselect All is selected.
I am using javascript.
<script type="text/javascript">
$(document).ready(function () {
var select = $(".radio-set").find("input:checked").val();
$('#<%=rdSelectContractor.ClientID %>').change(function () {
if (select = "0") {
$('.check_set_contractor').each(function () {
$(this).closest('table').find('input[type=checkbox]').prop('checked', true);
});
}
else if (select = "1") {
$('.check_set_contractor').each(function () {
$(this).closest('table').find('input[type=checkbox]').prop('checked', false);
});
}
});
});
</script>
My RadioButtonList
<asp:RadioButtonList ID="rdSelectContractor" runat="server" CssClass="radio-set">
<asp:ListItem Value="0">Select All</asp:ListItem>
<asp:ListItem Value="1">UnSelect All</asp:ListItem>
</asp:RadioButtonList>
My CheckBoxList
<asp:CheckBoxList ID="ContractorId" runat="server" RepeatDirection="Horizontal" RepeatColumns="6" CssClass="check_set_contractor"></asp:CheckBoxList>
Thank you so much