Link to home
Start Free TrialLog in
Avatar of sunisagar
sunisagar

asked on

checkall for checkboxes in gridview

In my  gridview  I have a checkbox  column , so, I have a check box as a header for that column.
The interaction part I want to use javascript. Does anyone have a good sample code for me ?
Thank you,


     
Avatar of Qaiser_Mehmood_Mughal
Qaiser_Mehmood_Mughal
Flag of Pakistan image

For complete details check this link. hope this will help u

http://www.shiningstar.net/articles/articles/javascript/checkboxes.asp


<SCRIPT LANGUAGE="JavaScript">
<!--       
// by Nannette Thacker
// http://www.shiningstar.net
// This script checks and unchecks boxes on a form
// Checks and unchecks unlimited number in the group...
// Pass the Checkbox group name...
// call buttons as so:
// <input type=button name="CheckAll"   value="Check All"
      //onClick="checkAll(document.myform.list)">
// <input type=button name="UnCheckAll" value="Uncheck All"
      //onClick="uncheckAll(document.myform.list)">
// -->

<!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
      field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
      field[i].checked = false ;
}
//  End -->
</script>
This link is also very nice, and its for gridview control checkboxs.

http://weblog.vb-tech.com/nick/archive/2005/09/26/1300.aspx

function doAllChecks()
{
 re = new RegExp('_chkMove')


 if(document.Form1['Datagrid1_ctl1_chkAction'].checked == true)
 {
   for (var iCount=0;iCount
  {
   elm = document.forms[0].elements[iCount]

    if (elm.type == 'checkbox') {

     if (re.test(elm.id)) {
      elm.checked = true;
     }
    }
   
  }
 }
 else
 {
 
 
  for (var iCount=0;iCount
  {
   elm = document.forms[0].elements[iCount]

    if (elm.type == 'checkbox') {

     if (re.test(elm.id)) {
      elm.checked = false;
     }
    }
   
  }
 }
}
ASKER CERTIFIED SOLUTION
Avatar of sunisagar
sunisagar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial