Gridview Header Checkbox Select and Deselect using client side JavaScript.

Posted by vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 389
I am assuming that we have a Gridview control with Checkboxes inside it.

Now,write a javascript code as
<script type="text/javascript" language="javascript">
function Check_UncheckAll(Checkbox)
var Grid_vw_Emp = document.getElementById("<%=grid_emp.ClientID %>");

for (i = 1;i<= Grid_vw_Emp.rows.length-1;i++)
Grid_vw_Emp.rows[i].cells[0].getElementsByTagName("INPUT")[0].checked = Checkbox.checked;

Here,cells[0] means 0 index that is Checkbox index position.
Call above Javascript method on Checkbox OnClick event as:-

<asp:CheckBox ID="chkboxSelectAll" runat="server" onclick = "Check_UncheckAll(this);" />

Comments or Responses

Login to post response