Click here to Skip to main content
15,888,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am suffering from a very unusual problem. I wrote a java script which was working fine earlier making all the check boxes checked if I select the header checkbox in grid view but than when I added other functionality and controls to my page it stopped working. I am unable to guess why is it happening. My code of javascript is :-
JavaScript
function SelectAll(id) {

        var frm = document.forms[0];

        for (i=0;i<frm.elements.length;i++) {

            if (frm.elements[i].type == "checkbox") {

                frm.elements[i].checked = document.getElementById(id).checked;

            }

        }

    }  


and c# code for the same is:
C#
if (e.Row.RowType == DataControlRowType.Header)
       {

           ((CheckBox)e.Row.FindControl("chkAll")).Attributes.Add("onclick", "javascript:SelectAll('" + ((CheckBox)e.Row.FindControl("chkAll")).ClientID + "')");
       }


Please help guyz !
Posted

Hi,
You can find some of the best article to do this task. Follow the links:
Selecting / Deselecting all the CheckBoxes Inside a GridView[^]
Check/uncheck CheckBox in a GridView using Javascript[^]
All the best.
--Amit
 
Share this answer
 
Comments
Taresh Uppal 30-Jun-12 1:47am    
Thanx for your help but as I said ealrier it was working and now its not..I am confused why is it happening..
Taresh Uppal 30-Jun-12 1:51am    
and earlier i ws using this code snippet earlier too
Selecting / Deselecting all the CheckBoxes Inside a GridView[^]
and now agin implemented it..still no go...
Ranjith Reddy CSE 30-Jun-12 2:01am    
Boss, How to delete that particular records after Selection of that checkboxes.

Please advice me. THANKS.
Taresh Uppal 30-Jun-12 3:46am    
ranjith for that u need to select that checkbox and take a button control in your grid view. On rowdeleting method traverse through the rows that which checkbox is checked and accordingly delete the row corresponding to it.

check it:
http://www.codeproject.com/Answers/397039/Delete-rows-from-datgridview-and-database-access#answer2
Hi ,
Check this
Here[^]
Best Regards
M.Mitwalli
 
Share this answer
 
Comments
Taresh Uppal 30-Jun-12 3:42am    
as i have told u due to some reason javascript is not getting fired on my page..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900