Javascript

Using javascript check all the check boxes in Datalist:


<script type="text/javascript">

   function CheckAllDataListCheckBoxes(aspCheckBoxID)
   { 
   alert(aspCheckBoxID);
   if(aspCheckBoxID == "a_Sel")
   {
       re = new RegExp(':' + aspCheckBoxID + '$')      
       for(i = 0; i < document.forms[0].elements.length; i++)
        {       
          elm = document.forms[0].elements[i]      
          if (elm.type == "checkbox")
          {
//               alert(elm.name);
//               if (re.test(elm.name))
//               {
                    elm.checked = true
                //}
          }
        }
      }
      else
      {
       for(i = 0; i < document.forms[0].elements.length; i++)
        {       
          elm = document.forms[0].elements[i]      
          if (elm.type == "checkbox")
          {
//               alert(elm.name);
//               if (re.test(elm.name))
//               {
                    elm.checked = false
                //}
          }
        }
      }
    }

    </script>


Call this above javascript function in anchor tag onclick event like,

<a name="a_Sel"  onclick="CheckAllDataListCheckBoxes(this.name)">Select All</a>