Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

910 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

24 Experts available now in Live!

Get 1:1 Help Now