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. Web Development
  3. ASP.NET
  4. Check all checkboxes as the header checkbox is checked

Check all checkboxes as the header checkbox is checked

Scheduled Pinned Locked Moved ASP.NET
4 Posts 4 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.
  • N Offline
    N Offline
    NET India
    wrote on last edited by
    #1

    Hi All, How all the checkboxes get checked as the header checkbox is checked or selected

    M S M 3 Replies Last reply
    0
    • N NET India

      Hi All, How all the checkboxes get checked as the header checkbox is checked or selected

      M Offline
      M Offline
      mareers
      wrote on last edited by
      #2

      use javascript

      ------------------------------ If u think u can, u can. If u think u can't, u r right.

      1 Reply Last reply
      0
      • N NET India

        Hi All, How all the checkboxes get checked as the header checkbox is checked or selected

        S Offline
        S Offline
        Sherin Iranimose
        wrote on last edited by
        #3

        you can create controll array. And map each array item to each check box. so u need to iterate through that array to check or uncheck..


        If U Have Interest, U Can... Sherin Iranimose


        1 Reply Last reply
        0
        • N NET India

          Hi All, How all the checkboxes get checked as the header checkbox is checked or selected

          M Offline
          M Offline
          meeram395
          wrote on last edited by
          #4

          Hi, Do as follows. Please let me know if you face any issues. 1. First, code in the aspx page, html view as follows: <asp:datagrid id="dgAnalDelete" runat="server"><Columns> <asp:BoundColumn HeaderText="Sl.No"></asp:BoundColumn> <asp:TemplateColumn HeaderText="Visible"> <HeaderTemplate> <input type="checkbox" id="checkAll" onclick="CheckAll(this);" runat="server" NAME="checkAll">(Un)Select All </HeaderTemplate> <ItemTemplate> <asp:Checkbox runat="server" ID="chkID" Checked='<%# GetChecked(DataBinder.Eval(Container, "DataItem.Selected").ToString()) %>'> </asp:Checkbox> </ItemTemplate> </Columns> </asp:datagrid> 2. Write the javascript function as follows: function CheckAll( checkAllBox ) { var frm = document.Form1 ; var actVar = checkAllBox.checked ; for(i=0;i< frm.elements.length;i++) { e=frm.elements[i]; if ( e.type=='checkbox' && e.name.indexOf("chkID") != -1 ) e.checked= actVar ; } } Happy Coding!! ;-)

          Meeram395

          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