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. How to add a checkbox controlin the header of a DataGrid control

How to add a checkbox controlin the header of a DataGrid control

Scheduled Pinned Locked Moved ASP.NET
helptutorial
3 Posts 3 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.
  • A Offline
    A Offline
    Arun Hegde
    wrote on last edited by
    #1

    1. How to add a checkbox in the header(next to ‘Select All’) of the datagrid control. 2. If I select the header checkbox then all the other checkboxes should be automatically checked. 3. After the above thing is achieved,if I uncheck any of the checkboxes ,the header checkbox must be unchecked automatically. Please kindly help me in this issue Thanks a lot arun

    M T 2 Replies Last reply
    0
    • A Arun Hegde

      1. How to add a checkbox in the header(next to ‘Select All’) of the datagrid control. 2. If I select the header checkbox then all the other checkboxes should be automatically checked. 3. After the above thing is achieved,if I uncheck any of the checkboxes ,the header checkbox must be unchecked automatically. Please kindly help me in this issue Thanks a lot arun

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

      This is the java script for select-all /* Function for check all the check boxes in the Grid*/ function SelectAllCheckboxes(spanChk) { // Added as ASPX uses SPAN for checkbox var oItem = spanChk.children; var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0]; xState=theBox.checked; elm=theBox.form.elements; for(i=0;i

      1 Reply Last reply
      0
      • A Arun Hegde

        1. How to add a checkbox in the header(next to ‘Select All’) of the datagrid control. 2. If I select the header checkbox then all the other checkboxes should be automatically checked. 3. After the above thing is achieved,if I uncheck any of the checkboxes ,the header checkbox must be unchecked automatically. Please kindly help me in this issue Thanks a lot arun

        T Offline
        T Offline
        Tirthadip
        wrote on last edited by
        #3

        hi Arun, 1.you need a Template Column for this . Add a template column to your datagrid. put two checkboxes in the Header and ItemTemplate column. 2.for the second query you can do it in two ways. a.if you want to do it in the client side....... you have to put your code in the onclick event handler of the header checkbox.put onclick="checkingboxes()" here checkingboxes() is the client side Javascript function. function checkingboxes() { dgChkItem.checked=true;// dgChkItem is the id of ItemTemplate checkbox. } b. if you want to do it in the server side..... make the AutoPostBack property of the header checkbox to true. In the CheckedChanged event handler put code for checking the ItemTemplate checkbox in the dgChkHead_CheckedChanged(....) event put e.Item.FindControl("dgChkItem").checked=true; Tirthadip Live life to the fullest

        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