Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. selecting check box

selecting check box

Scheduled Pinned Locked Moved C#
csshelp
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chithra r
    wrote on last edited by
    #1

    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

    V 1 Reply Last reply
    0
    • C chithra r

      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

      V Offline
      V Offline
      Vimal Raj
      wrote on last edited by
      #2

      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

      C 1 Reply Last reply
      0
      • V 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

        C Offline
        C Offline
        chithra r
        wrote on last edited by
        #3

        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

        V 1 Reply Last reply
        0
        • C chithra r

          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

          V Offline
          V Offline
          Vimal Raj
          wrote on last edited by
          #4

          Hi, Just make the following two changes and it will work. update this line ckbHeader.Attributes.Add("onclick", "SelectAll(" + ckbHeader.ClientID.ToString() + ")"); to ckbHeader.Attributes.Add("onclick", "SelectAll(this)"); and update this javascript line var checkboxHeader = document.getElementById(idHeaderCheckbox); to var checkboxHeader = idHeaderCheckbox; Do let me know if u need more info, Cheers...

          Happy Programming, Vimal Raj MCAD.Net www.techisolutions.blogspot.com

          C 1 Reply Last reply
          0
          • V Vimal Raj

            Hi, Just make the following two changes and it will work. update this line ckbHeader.Attributes.Add("onclick", "SelectAll(" + ckbHeader.ClientID.ToString() + ")"); to ckbHeader.Attributes.Add("onclick", "SelectAll(this)"); and update this javascript line var checkboxHeader = document.getElementById(idHeaderCheckbox); to var checkboxHeader = idHeaderCheckbox; Do let me know if u need more info, Cheers...

            Happy Programming, Vimal Raj MCAD.Net www.techisolutions.blogspot.com

            C Offline
            C Offline
            chithra r
            wrote on last edited by
            #5

            hi vimal raj it is working perfectly..thanx for your valuable suggestion and your time.

            pintoo

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups