Solved

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

Posted on 2010-08-20
3
891 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now