Solved

checkall for checkboxes in gridview

Posted on 2008-06-11
3
357 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
  • 2
3 Comments
 
LVL 5

Expert Comment

by:Qaiser_Mehmood_Mughal
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now