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. enable checkbox inside gridview javascript

enable checkbox inside gridview javascript

Scheduled Pinned Locked Moved ASP.NET
javascript
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.
  • B Offline
    B Offline
    Bikash Shrestha From Nepal
    wrote on last edited by
    #1

    i do have 2 gridviews in my page, both of which contains check boxes. i need to uncheck and enable second gridview when any of the checkbox from first gridview is selected and vice versa.

    A A 2 Replies Last reply
    0
    • B Bikash Shrestha From Nepal

      i do have 2 gridviews in my page, both of which contains check boxes. i need to uncheck and enable second gridview when any of the checkbox from first gridview is selected and vice versa.

      A Offline
      A Offline
      A5KEXTREME
      wrote on last edited by
      #2

      Here is a demo example, i m takin two grids and than disabling and enabling the second one through checkbox click in first one through javascript. .aspx code

      Javascript:-

          function SelectAll(id) {
              //get reference of GridView control
                              if(document.getElementById(id).checked)
                              {
                                  var grid = document.getElementById("<%= GridView2.ClientID %>")
                                  grid.style.visibility = "visible";
                              }
                              else {
                                  var grid = document.getElementById("<%= GridView2.ClientID %>")
                                  grid.style.visibility = "hidden";
                              }
                          
          }
      

      modified on Friday, May 7, 2010 4:00 AM

      J 1 Reply Last reply
      0
      • B Bikash Shrestha From Nepal

        i do have 2 gridviews in my page, both of which contains check boxes. i need to uncheck and enable second gridview when any of the checkbox from first gridview is selected and vice versa.

        A Offline
        A Offline
        Arindam Tewary
        wrote on last edited by
        #3

        1. You need to put a javascript function in each checkbox in row in first gridview. in that checkbox you call the javascript function as follows

        ;

        2. Following would be your javascript function defination

        function EnableBelowGrid()
        {
        var chkBoxID = arguments[0];
        if(document.getElementByID(chkBoxID).checked)
        {
        document.getElementById('<%=BelowGridID.ClientID%>').disabled = true
        }
        return false;
        }

        Assumed that "BelowGridID" is the ID of your below grid as you have refered.

        Thanks, Arindam D Tewary

        1 Reply Last reply
        0
        • A A5KEXTREME

          Here is a demo example, i m takin two grids and than disabling and enabling the second one through checkbox click in first one through javascript. .aspx code

          Javascript:-

              function SelectAll(id) {
                  //get reference of GridView control
                                  if(document.getElementById(id).checked)
                                  {
                                      var grid = document.getElementById("<%= GridView2.ClientID %>")
                                      grid.style.visibility = "visible";
                                  }
                                  else {
                                      var grid = document.getElementById("<%= GridView2.ClientID %>")
                                      grid.style.visibility = "hidden";
                                  }
                              
              }
          

          modified on Friday, May 7, 2010 4:00 AM

          J Offline
          J Offline
          Jipin
          wrote on last edited by
          #4

          thanks , but i need to enable asp.net checkbox inside gridview .

          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