Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes.

Ahhhh its 2:00 AM and me little sleepy! Anyway someone asked me on the that how can I deselect all the checkboxes in the gridview control when a single checkbox is unchecked. Offcourse this is very easy if you are using and want this functionality to happen when header checkbox is checked and unchecked. But the request was that when any checkbox in the GridView is unchecked it should disable all the checkboxes.

Here is the code which does the same:

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
                    <asp:TemplateField HeaderText="AutoNumber">
                          ID="MyCheckBox" runat="server" />
                            ID="chkAll" runat="server" />
             function DeSelectCheckBoxes(spanChk) 
// Added as ASPX uses SPAN for checkbox
var oItem = spanChk.children;
    var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];
// this means it is deselected
if(xState == false
if(elm[i].type=="checkbox" && elm[i].id!
checked false;       

Hope it helps!

powered by IMHO 1.3

Posted on Tuesday, March 7, 2006 12:05 AM | Back to top

Comments on this post: DeSeleting All CheckBoxes When DeSelect One Item CheckBox

# re: DeSeleting All CheckBoxes When DeSelect One Item CheckBox
Requesting Gravatar...

Sorry azam but this code is not working for usercontrols, i.e if grid is used in usercontrol, the id of each checkbox is different so this code fails...any way around....
Left by Abhishek on Jul 11, 2006 5:59 AM

Your comment:
 (will show your gravatar)

Copyright © Mohammad Azam | Powered by: