﻿  function SelectAll(id,gridView)
        {
            //get reference of GridView control
            //var grid = document.getElementById("<%= gvGradeBook.ClientID %>");
            var grid = document.getElementById("<%= gridView.ClientID %>");
            //variable to contain the cell of the grid
            var cell;
            
            if (grid.rows.length > 0)
            {
                //loop starts from 1. rows[0] points to the header.
                for (i=1; i<grid.rows.length; i++)
                {
                    //get the reference of first column
                    cell = grid.rows[i].cells[0];
                    
                    //loop according to the number of childNodes in the cell
                    for (j=0; j<cell.childNodes.length; j++)
                    {           
                        //if childNode type is CheckBox                 
                        if (cell.childNodes[j].type =="checkbox")
                        {
                        //assign the status of the Select All checkbox to the cell checkbox within the grid
                            cell.childNodes[j].checked = document.getElementById(id).checked;
                        }
                    }
                }
            }
        }

       

function selectUnselectCheckboxes(chkBoxHeaderId, chkBoxIdInGrid, gridViewId) 
{

   var gridViewElem = document.getElementById(gridViewId);
   //get the no of rows<tr> generated by the gridview
   var gridRowsCount = gridViewElem.rows.length;
   //the controls in the gridview will have the following suffix in their ids 'GridView1_ctl0n'
   //the first element starts with 2 e.g. GridView1_ctl02_chkEmployee(first element)... GridView1_ctl10_chkEmployee(9th element)
   for (i = 2; i <= gridRowsCount; i++) 
   {

     var ctlIndex = eval(i);
     if (ctlIndex < 10)
           ctlIndex = '0' + i;

     var chkBoxIdFull = gridViewElem.id + '_ctl' + ctlIndex + '_' + chkBoxIdInGrid;
     var chkBoxElem = document.getElementById(chkBoxIdFull);
     if (chkBoxElem != null) 
     {
         //if the header checkbox is checked, then check the checkboxes in the grid
         if (document.getElementById(chkBoxHeaderId).checked)
         {
              if(chkBoxElem.disabled==false)
                  chkBoxElem.checked = true;
          }    
         else
              chkBoxElem.checked = false;
     }
   }
}





function SelectRadioButton(value, radionButtonName) 
{

    var elements = document.getElementsByName(radionButtonName);
    var count = elements.length - 1;
    for (i = 0; i <= count; i++) 
    {
        if (elements[i].value == value)
            elements[i].checked = true;
    }
}

