Solved

How to show/hide Child gridview based on CheckBox Click in Parent Grid No PostBack

Posted on 2010-08-20
3
898 Views
Last Modified: 2013-11-11
I am not a JavaScript expert and I have a need to display a hidden child gridview when the parent gridview checkbox is checked or hidden when the parent checkbox is unchecked. The child gridview is initially not displayed.
I have attached code that I have developed so far.

Experts please help. Thanks.  CodeExample.txt
0
Comment
Question by:mconti41
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
meagain35 earned 500 total points
ID: 33485557
Try implementing something like this around your child grid.




<html>
<head>

<script language='javascript'>
  function show_hide() {
    var action = "hide";

    if(document.getElementById('chk').checked == true) {
        action = "show";
     } else {
        action = "hide";
     }
    
    if (action == "hide") {
       document.getElementById('myGridDiv').style.display="none";
    }
    
    if(action == "show") {
       document.getElementById('myGridDiv').style.display="block";
    }
  }
</script>

</head>

<body>
<form name="form1">
  <input type="checkbox" onclick="show_hide()" id="chk">Show/Hide</input>

  <div id="myGridDiv" style="width:100px; height:100px; background-color:#FF0000; display:none;">
     My Grid
  </div>
</form>
</body>

</html>

Open in new window

0
 

Author Comment

by:mconti41
ID: 33486249
Thanks for the response...

The result is excellent for the first gridview row but the other gridview rows do not respond to a click> Do you have any thoughts on this.




0
 

Author Closing Comment

by:mconti41
ID: 33488879
Solution only handled first gridview row and not a multiple row gridview.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question