【问题标题】:TreeView bound from GridView selected row从 GridView 选定行绑定的 TreeView
【发布时间】:2013-10-08 06:57:32
【问题描述】:

我有两个如下表

PatientDetail - 1st table name     
PatientId --- primary key
firstname
lastname

Patexam - 2nd table name
PId ---- foreign key of first table PatientId
Exam

第一个表格在gridview中显示如下

<asp:GridView ID="gvDoctorList" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
                            AllowPaging="True" AllowSorting="True" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true">
                            <Columns>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:CheckBox runat="server" ID="chk" OnCheckedChanged="chk_CheckedChanged" />
                                        <asp:Label runat="server" ID="lblPID" Visible="false" Text='<%# Eval("PatientId") %>'></asp:Label>
                                    </ItemTemplate>

                                </asp:TemplateField>

                                <asp:BoundField DataField="PatientId" HeaderText="PatientId" SortExpression="PatientId" />
                                <asp:BoundField DataField="firstname" HeaderText="firstname" SortExpression="firstname" />
                                <asp:BoundField DataField="lastname" HeaderText="lastname" SortExpression="lastname" />

                                <asp:BoundField DataField="sex" HeaderText="sex" SortExpression="sex" />

                            </Columns>
                        </asp:GridView>
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyDatabaseConnectionString %>" 
                            SelectCommand="SELECT [PatientId],[firstname], [lastname], [sex] FROM [PatientDetails]"></asp:SqlDataSource>

现在,当我使用复选框从 gridview 中选择一行或多行时, 那时我想使用树视图将名字显示为第一个表中的根节点,并将考试显示为第二个表中的子节点。

代码怎么可能???

谢谢

【问题讨论】:

    标签: c# asp.net gridview treeview sql-server-2012


    【解决方案1】:

    有一个带有树视图控件的模板文件。处理选择行事件,传递选定的患者 ID 并获取检查名称并在树视图中填充值。

    【讨论】:

    • 如何在treeview中创建templatefield,能给我举个例子吗?
    猜你喜欢
    • 2013-05-25
    • 1970-01-01
    • 2011-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-23
    相关资源
    最近更新 更多