如何增强GridView中的“向下钻取"功能? [英] How to enhance the Drill Down feature in the GridView?

查看:137
本文介绍了如何增强GridView中的“向下钻取"功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是ASP.NET的新开发人员,我正在尝试开发具有向下钻取功能的GridView.我正在执行以下代码项目中的步骤,但是失败了,我不知道如何解决.

就我而言,我有两个表:

**课程表:CourseID,CoursName,GroupID **

**组表:GroupID GroupName **


(每个表中的第一个属性是主键)

我想在GridView中显示第二个表,当用户单击搜索图标图像时,将显示第一个表中的信息. 那怎么办?

我的ASP.NET:

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 the following post in the CodeProject but I failed and I don''t know how to fix it.

In my case, I have two tables:

**Course Table: CourseID, CourseName, GroupID**

**Group Table: GroupID GroupName**


(The first attribute in each table is the primary key)

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?

My ASP.NET:

<div align="center">


                <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"

                    DataKeyNames="CourseID" DataSourceID="SqlDataSource1">
                    <Columns>
                        <asp:TemplateField HeaderText="Item Details">
                            <ItemTemplate>
                                <table>
                                    <tr>
                                        <td>
                                            <img src="images/system-search-md.png" alt="click here to see details"

                                                 onclick='ToggleDisplay(<%# Eval("GroupID") %>);' style="cursor:pointer; height:15px; width:15px" />
                                        </td>
                                        <td<>
                                            <p><%# Eval("CourseID") %></p>
                                        </td>
                                        <td>
                                            <a href="Group.aspx?id=<%# Eval("CourseID") %>"><%# Eval("CourseName") %> </a>
                                        </td>
                                        <td>
                                            <%# Eval("CourseName") %>
                                        </td>
                                    </tr>

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

                <script language="JavaScript">
                    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';
                            }
                        }
                    }
</script>

                <asp:SqlDataSource ID="SqlDataSource1" runat="server"

                    ConnectionString="<%$ ConnectionStrings:testConnectionString %>"

                    SelectCommand="SELECT     dbo.groups.*, dbo.courses.*
                                    FROM         dbo.courses INNER JOIN
                                    dbo.groups ON dbo.courses.GroupID = dbo.groups.ID"></asp:SqlDataSource>
            </div>

推荐答案

ConnectionStrings:testConnectionString %> " span> SelectCommand =" > < /asp:SqlDataSource > < /div >
ConnectionStrings:testConnectionString %>" SelectCommand="SELECT dbo.groups.*, dbo.courses.* FROM dbo.courses INNER JOIN dbo.groups ON dbo.courses.GroupID = dbo.groups.ID"></asp:SqlDataSource> </div>


尝试关注链接.....

GridView内的可扩展面板 [ http://mosesofegypt.net/post/GridView-Grouping- Master-Detail-Drill-Down-Using-jQuery-AJAX.aspx [
Try Following Links.....

Expandable panel inside a GridView[^]

http://mosesofegypt.net/post/GridView-Grouping-Master-Detail-Drill-Down-Using-jQuery-AJAX.aspx[^]


这篇关于如何增强GridView中的“向下钻取"功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆