Solved

hide and display div in nested gridview

Posted on 2009-03-30
1
1,582 Views
Last Modified: 2013-11-07
I've used a javascript item from another posted question, but am finding it difficult to adapt it for a page with multiple mastergrids each containing nested gridviews. Hope that makes sense.

I have 7 mastergrids, each with a unique names. The problem I have is that the doc_id could appear in any number of mastergrids.  When clicking on the link to show the div it makes visible the first on it finds, even if it is not in the mastergrid you are currently viewing. I need it to open the div in the mastergrid/nested gridview that I m clicking.

Hope someone can point me in the right direction. I'm too tired now for looking ;-)
The JavaScript
 

<script type="text/javascript">

function ShowChildGrid(obj)

{

    var div = document.getElementById(obj);

    var img = document.getElementById('img' + obj);

    var theFlag = div.style.display == "none";

    div.style.display = (theFlag) ? "inline" : "none";

    img.src = (theFlag) ? "images/buttons/tl_arrow_down.gif" : "images/buttons/tl_arrow_straight.gif";

}

</script>
 

The button call
 

<a href="javascript:ShowChildGrid('div<%# Eval("doc_id") %>');">

                    <img id="imgdiv<%# Eval("doc_id") %>" 

                        alt="Click to show/hide documents" 

                        border="0" src="images/buttons/tl_arrow_straight.gif" />

                </a>
 

The div
 

<div id="div<%# Eval("doc_id") %>" style="display:none;position:relative;" >

Open in new window

0
Comment
Question by:craigywoos
1 Comment
 

Accepted Solution

by:
craigywoos earned 0 total points
ID: 24020246
Oh, it was so obvious. Of course it wasn't going to work.

I just needed to add a unique div id for each mastergrid.

So for this sample I've added MOD to uniquely identify this mastergrid. Just replace this for each mastergrid with something else.
Button call
 

<a href="javascript:ShowChildGrid('divMOD<%# Eval("doc_id") %>');">

                    <img id="imgdivMOD<%# Eval("doc_id") %>" 

                        alt="Click to show/hide documents" 

                        border="0" src="images/buttons/tl_arrow_straight.gif" />

                </a>
 
 

The div
 

<div id="divMOD<%# Eval("doc_id") %>" style="display:none;position:relative;" >

Open in new window

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

      Install BugTracker on Windows 2008 server Step 1:  Install windows 2008 server 32 bit OS and configure IIS. Step 2:  Install SQL server ( SQL server 2005 or SQL server 2005 Express edition. The installer for 2008  version isn’t very f…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

939 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

7 Experts available now in Live!

Get 1:1 Help Now