bob white

bob white

  • NA
  • 13
  • 99.9k

How to capture server control from Jscript and check if a control check box is selected

Jan 25 2011 4:41 PM

I have a gridview that contains check box in first column for each row.
I also have a check box outside the grid view called
>>>>
<asp:CheckBox ID="chkSelectAll" runat="server" Text="Select All"     AutoPostBack="true"
 OnCheckedChanged="chkSelectAll_CheckedChanged" />
I either can select more than one checkboxes from gridview then click on a button to get the number of checkboxes selected OR I click on SelectAll checkbox ( which is outside the gridview ) which check all the checkboxes in the gridview and give me the number of checkedboxes.  When I select inidividual checkboxes inside the gridview,  th e count of number of checkboxes is correct ( displayed in a lable ) However;
When I click "SelectAll" check box, it give me total of all checkboxes chekced in the
gridview  + 1 ( extra )  I am trying to get rid of this extra one by checking if this "Allcheckbox" is selected to  so I subtract one from the total count .. like this

// java code  ... code not shown does capture the total count into c variable
  varAllChecked = document.getElementById('chkSelectAll');
  if (varAllChecked.checked== true)
        litCount.innerText = c - 1;
  else
        litCount.innerText = c;

this is not working any idea.
Thanks Bob

Answers (1)