selecting check box
-
hi all in my application iam having a grid which contains a check box at the top and name field inside and check boxes to select the particular name.(like in mail boxes).i can select the particular checkbox if i want..till here no problem..but if i want to select all the check boxes by clicking the check box at the top(note this has to be done by clicking the check box and not by any buttons like unread button as in gmail or yahoo).can anyone give me code to do it... thanks in advance..
pintoo
-
hi all in my application iam having a grid which contains a check box at the top and name field inside and check boxes to select the particular name.(like in mail boxes).i can select the particular checkbox if i want..till here no problem..but if i want to select all the check boxes by clicking the check box at the top(note this has to be done by clicking the check box and not by any buttons like unread button as in gmail or yahoo).can anyone give me code to do it... thanks in advance..
pintoo
Hi, You can checkout my blog at http://techisolutions.blogspot.com/2008/02/datagridview-checkbox-select-all.html. I hope that you are using a gridview control. Cheers...
Happy Programming, Vimal Raj
-
Hi, You can checkout my blog at http://techisolutions.blogspot.com/2008/02/datagridview-checkbox-select-all.html. I hope that you are using a gridview control. Cheers...
Happy Programming, Vimal Raj
hi i have tried this link...it is not working ..iam giving the code herewith.do tell me what iam missing.. ASPX PAGE
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> <script language="javascript" type="text/javascript"> function SelectAll(idHeaderCheckbox) { var checkboxHeader = document.getElementById(idHeaderCheckbox); var hdnCheckboxIDs = document.getElementById("hdnCheckboxID") ; var arrCheckboxIDs = hdnCheckboxIDs.value.split(","); if(checkboxHeader.checked == true) { for(var i=0 ; i < arrCheckboxIDs.length ; i++ ) { if(arrCheckboxIDs[i] != "") { var ckbItem = document.getElementById(arrCheckboxIDs[i]); ckbItem.checked = true; } } } else if(checkboxHeader.checked == false) { for(var i=0 ; i < arrCheckboxIDs.length ; i++ ) { if(arrCheckboxIDs[i] != "") { var ckbItem = document.getElementById(arrCheckboxIDs[i]); ckbItem.checked = false; } } } } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound"> <Columns> <asp:TemplateField> <HeaderTemplate> <asp:CheckBox ID="ckbHeader" runat="server" /><br /> </HeaderTemplate> <ItemTemplate> <asp:CheckBox ID="ckbItem" runat="server" /><br /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Name" HeaderText="Emp Name" /> <asp:BoundField DataField="EmpID" HeaderText="Emp Id" /> <asp:BoundField DataField="Age" HeaderText="Emp Age" /> </Columns> </asp:GridView> <input type="hidde
-
hi i have tried this link...it is not working ..iam giving the code herewith.do tell me what iam missing.. ASPX PAGE
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> <script language="javascript" type="text/javascript"> function SelectAll(idHeaderCheckbox) { var checkboxHeader = document.getElementById(idHeaderCheckbox); var hdnCheckboxIDs = document.getElementById("hdnCheckboxID") ; var arrCheckboxIDs = hdnCheckboxIDs.value.split(","); if(checkboxHeader.checked == true) { for(var i=0 ; i < arrCheckboxIDs.length ; i++ ) { if(arrCheckboxIDs[i] != "") { var ckbItem = document.getElementById(arrCheckboxIDs[i]); ckbItem.checked = true; } } } else if(checkboxHeader.checked == false) { for(var i=0 ; i < arrCheckboxIDs.length ; i++ ) { if(arrCheckboxIDs[i] != "") { var ckbItem = document.getElementById(arrCheckboxIDs[i]); ckbItem.checked = false; } } } } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound"> <Columns> <asp:TemplateField> <HeaderTemplate> <asp:CheckBox ID="ckbHeader" runat="server" /><br /> </HeaderTemplate> <ItemTemplate> <asp:CheckBox ID="ckbItem" runat="server" /><br /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Name" HeaderText="Emp Name" /> <asp:BoundField DataField="EmpID" HeaderText="Emp Id" /> <asp:BoundField DataField="Age" HeaderText="Emp Age" /> </Columns> </asp:GridView> <input type="hidde
Hi, Just make the following two changes and it will work. update this line
ckbHeader.Attributes.Add("onclick", "SelectAll(" + ckbHeader.ClientID.ToString() + ")");
tockbHeader.Attributes.Add("onclick", "SelectAll(this)");
and update this javascript linevar checkboxHeader = document.getElementById(idHeaderCheckbox);
tovar checkboxHeader = idHeaderCheckbox;
Do let me know if u need more info, Cheers...Happy Programming, Vimal Raj MCAD.Net www.techisolutions.blogspot.com
-
Hi, Just make the following two changes and it will work. update this line
ckbHeader.Attributes.Add("onclick", "SelectAll(" + ckbHeader.ClientID.ToString() + ")");
tockbHeader.Attributes.Add("onclick", "SelectAll(this)");
and update this javascript linevar checkboxHeader = document.getElementById(idHeaderCheckbox);
tovar checkboxHeader = idHeaderCheckbox;
Do let me know if u need more info, Cheers...Happy Programming, Vimal Raj MCAD.Net www.techisolutions.blogspot.com