SelectAll checkbox not checked
I have a grid in which i have a "Sselect" checkbox as a column in the grid as below<input type="checkbox" class="checkClass" name="SelectAllName" value="Select" id="selectAll" onchange="selectall()" />
And the rows in the grid are dynamic where i have checkboxes in each row as below:
<%=Html.CheckBox(string.Format("TestDetails[{0}].Delete", count), Model.TestDetails[count].Delete, new { @class = "checkClass" })%>
My selectall function is as below:
function selectall() {
$('#selectAll').click(function (event) {
if (this.checked) {
$('.checkClass').each(function () {
this.checked = true;
});
} else {
$('.checkClass').each(function () {
this.checked = false;
});
}
});
}
Issue: When i click the "Select" checkbox in the grid column, all the checkboxes in all the rows are checked but the "Select" checkbox is not checked. Please help me to solve the issue