How to enhance the Drill Down feature in the GridView?
<p>I am a new ASP.NET developer and I am trying to develop a GridView with Drill-Down Feature. I am following the steps in <a href="http://www.codeproject.com/KB/webforms/Collapsible_GridView_Data.aspx" rel="nofollow">the following post in the CodeProject</a> but I failed and I don't know how to fix it. </p>

<p>In my case, I have two tables: </p>

<p><strong>Course Table: CourseID, CourseName, GroupID</strong> </p>

<p><strong>Group Table: GroupID GroupName</strong></p>

<p>(The first attribute in each table is the primary key)</p>

<p>I want to show the second table in the GridView and when the user clicks on the search icon image, the information in the first table will be displayed. So HOW TO DO THAT?</p>

<p>My ASP.NET:</p>

<pre><code>&lt;div align="center"&gt;


                &lt;asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                    DataKeyNames="CourseID" DataSourceID="SqlDataSource1"&gt;
                    &lt;Columns&gt;
                        &lt;asp:TemplateField HeaderText="Item Details"&gt;
                            &lt;ItemTemplate&gt;
                                &lt;table&gt;
                                    &lt;tr&gt;
                                        &lt;td&gt;
                                            &lt;img src="images/system-search-md.png" alt="click here to see details" 
                                                 onclick='ToggleDisplay(&lt;%# Eval("GroupID") %&gt;);' style="cursor:pointer; height:15px; width:15px" /&gt;
                                        &lt;/td&gt;
                                        &lt;td&lt;&gt;
                                            &lt;p&gt;&lt;%# Eval("CourseID") %&gt;&lt;/p&gt;
                                        &lt;/td&gt;
                                        &lt;td&gt;
                                            &lt;a href="Group.aspx?id=&lt;%# Eval("CourseID") %&gt;"&gt;&lt;%# Eval("CourseName") %&gt; &lt;/a&gt;
                                        &lt;/td&gt;
                                        &lt;td&gt;
                                            &lt;%# Eval("CourseName") %&gt;
                                        &lt;/td&gt;
                                    &lt;/tr&gt;

                                    &lt;tr&gt;
                                        &lt;td colspan="4"&gt;
                                            &lt;div id'coldiv&lt;%# Eval("GroupID") %&gt;' style="display:none;"&gt;
                                                &lt;asp:Literal runnat="server" ID="ltrl" Text='&lt;%# Eval("GroupName") %&gt;'&gt;&lt;/asp:Literal&gt;
                                            &lt;/div&gt;
                                        &lt;/td&gt;
                                    &lt;/tr&gt;
                                &lt;/table&gt;
                            &lt;/ItemTemplate&gt;
                        &lt;/asp:TemplateField&gt;
                    &lt;/Columns&gt;
                &lt;/asp:GridView&gt;

                &lt;script language="JavaScript"&gt;
                    function ToggleDisplay(id) {
                        var elem = document.getElementById('coldiv' + id);
                        if (elem) {
                            if (elem.style.display != 'block') {
                                elem.style.display = 'block';
                                elem.style.visibility = 'visible';
                            }
                            else {
                                elem.style.display = 'none';
                                elem.style.visibility = 'hidden';
                            }
                        }
                    }
&lt;/script&gt;

                &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="&lt;%$ ConnectionStrings:testConnectionString %&gt;" 
                    SelectCommand="SELECT     dbo.groups.*, dbo.courses.*
                                    FROM         dbo.courses INNER JOIN
                                    dbo.groups ON dbo.courses.GroupID = dbo.groups.ID"&gt;&lt;/asp:SqlDataSource&gt;
            &lt;/div&gt;
</code></pre>
