Santosh Kumar

Santosh Kumar

  • NA
  • 126
  • 60.2k

CheckBox List losing the checkbox checked after post back

Nov 6 2014 6:37 AM
Hi,

I have check box list and a check box, After binding the data to the checkbox, if we select the all checkboxes then the main checkbox gets selected its fine till now but when we unselect any check box in checkbox list and clicks a button then all checkboxes in the checkboxlist getting unchecked.


How to Hold the checked items of the checkbox list even after the post back.

Javascript code
 
function pageLoad(sender, args) 
{ CheckAllProject();
}

 
function CheckAllProject () {         
$("[id*=lbxProjectList]").focus(function () {
if ($("[id*=lbxProjectList] input:checked").length == $("[id*=lbxProjectList] input").length) {
$("[id*=CheckBox1]").attr("checked", "checked");
} else {
$("[id*=CheckBox1]").removeAttr("checked");
}
});
}






It Looks like in the following way

Project List:CheckBox Select All Projects
Checkbox 1 Project1
Checkbox 2 Project2


Button Submit

Answers (5)