zoukankan      html  css  js  c++  java
  • DataRelation 实现父子表 父子级 Repeater的嵌套使用

    原文发布时间为:2009-05-21 —— 来源于本人的百度文章 [由搬家工具导入]

    DataRelation 实现父子表

            if (!IsPostBack)
            {
                using (OleDbConnection con = new OleDbConnection(cn))
                {
                    DataSet ds = new DataSet();

                    OleDbDataAdapter dr1 = new OleDbDataAdapter("select * from km", con);
                    OleDbDataAdapter dr2 = new OleDbDataAdapter("select * from km1", con);
                    dr1.Fill(ds, "tb1");
                    dr2.Fill(ds, "tb2");
                    ds.Relations.Add("newtb", ds.Tables[0].Columns["id"], ds.Tables[1].Columns["flag"]);
                    Repeater1.DataSource = ds;
                    Repeater1.DataBind();

                }
            }

    <asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
          <div class="adminleft" id='admin<%# Eval("id") %>'>
       <h2 id='h<%# Eval("id") %>' onmouseout="fff('h<%# Eval("id") %>')" onmouseover="f('h<%# Eval("id") %>')" onclick="javascript:location.href='showbj.aspx?flag=<%# Eval("id") %>&na=<%# Eval("subject") %>'"><%#Eval("subject") %></h2>
          <ul>
            <asp:Repeater ID="Repeater2" runat="server" DataSource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("newtb") %>' OnItemCommand="Repeater1_ItemCommand">
            <ItemTemplate>
            <li><asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%#Eval("["flag"]") %>' CommandName="re"><%#Eval("["subject"]") %></asp:LinkButton></li>
            </ItemTemplate>
            </asp:Repeater>
          </ul>
          </div>
        </ItemTemplate>
        </asp:Repeater>

  • 相关阅读:
    ADC测试matlab代码
    matlab的滤波器仿真——低通滤波器与插值滤波器
    PDF转Image最终方案
    多线程和蕃茄炒蛋
    git学习总结
    踩坑了,当前目录问题
    Angular 1.x 升级到 Angular 2
    打造AngularJs2.0开发环境
    发布一个自用的ansi转utf8程序
    用itextsharp打印pdf示例
  • 原文地址:https://www.cnblogs.com/handboy/p/7153309.html
Copyright © 2011-2022 走看看