Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

checkall for checkboxes in gridview

Posted on 2008-06-11
3
Medium Priority
?
407 Views
Last Modified: 2008-07-05
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,


     
0
Comment
Question by:sunisagar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Expert Comment

by:Qaiser_Mehmood_Mughal
ID: 21766638
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>
0
 
LVL 5

Expert Comment

by:Qaiser_Mehmood_Mughal
ID: 21766647
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;
     }
    }
   
  }
 }
}
0
 

Accepted Solution

by:
sunisagar earned 0 total points
ID: 21782338
Do you have a working  sample of this ?.
What if one of the checkboxes get uncheck in the gridview tahn we have to uncheck the checkbox in the header, How to do that?.

And in the code  " if(document.Form1['Datagrid1_ctl1_chkAction'].checked == true)
"
is Datagrid1_ctl_chkAction" the id of the header checkbox ?
and about the regular expression  re = new RegExp('_chkMove')
waht happens here ?. what is  "_chkMove"  the id of the checkbox in the columns ?

Please attach a sample working code if you haveone for the GridView
Thank you
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question