Check/Uncheck Checkboxes in Gridview.

Posted by vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 385
Below is the simple trick to select and unselect checkboxes inside gridview:-
Our Gridview has a Id called grid_view_employee and chk is our Header checkbox also in gridview.

function check_all_check_boxes(chk)
var grid_employee = document.getElementById('<%=grid_view_employee_details.ClientID %>');

for (row_index = 1;row_index <=grid_employee.rows.length-1;row_index++)
grid_employee.rows[row_index].cells[0].getElementsByTagName("input")[0].checked = chk.checked;

Now,call above function on Header Checkbox onclik event as shown below:-
<asp:checkbox id="chk_check_all" runat="server" onclick = "check_all_check_boxes(this);"/>

Comments or Responses

Login to post response