Solved

checkall for checkboxes in gridview

Posted on 2008-06-11
3
391 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Link not working 6 41
Bootstrap question 4 26
Slush on text 2 10
Broken .resx file generating errors 18 15
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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.

763 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