CheckBox SelectAll / DeSelectAll using Javascript...?

In this artical i'm trying to explain CheckBox SelectAll and DeSelectAll. In my page header itself i have a CheckBox Control once i click on that header checkbox all checkboxes in DataRow need to checked. Again i click on Header Checkbox need to deselect all checkboxes.

CheckBox SelectAll / DeSelectAll

In this artical i'm trying to explain how to select all checkboxes and how to deselect all checboxes using single click.
For this i'm introducing Javascript function using this javascript function easy to select all checkboxes and deselect all checkboxes and call that javascritp function in control itself.


for Select and DeSelect All CheckBoxes purpose i wrote some javascript function. Use below lines of code.

< script type="text/Javascript" >

function Check(parentChk,container)
var elements = document.getElementsByTagName("INPUT");
for(i=0; i {
if(parentChk.checked == true)
if( IsCheckBox(elements[i]) && IsMatch(elements[i].id,container))
elements[i].checked = true;
if( IsCheckBox(elements[i]) && IsMatch(elements[i].id,container))
elements[i].checked = false;
< script>

Source code

Call that Javascript function in header control checkbox.

<asp:GridView ID="GV" runat="server" ShowFooter="false" Width="100%"
EnableModelValidation="True" ForeColor="#333333"
GridLines="Vertical" AutoGenerateColumns="false" >

<asp:TemplateField >
<input id="HchkSelect" type="checkbox" onclick="javascript:Check(this,'GV');" />
<asp:CheckBox ID="chkSelect" runat="server" />
<ItemStyle HorizontalAlign="center" />

Select/Deselect All


Guest Author: Arecg19 Sep 2013

When you watch the Texans' DE play, its easy to be impressed with his athletic ability, speed up the field and his power at the point of attack. That's legit talent right there. But let's not forget about the technique Watt displays with his hands. He can “press" an offensive lineman and create some separation to work his counter moves. Fast and violent with the hands. That's what I took from the game. CSS10-26

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: