zoukankan      html  css  js  c++  java
  • .net实现主细表DataRelation

    程序代码:

    string sql = "select *  from used_infotype  where superid<=0 order by train asc select * from used_infotype where superid>0";
            DataSet ds = DBHelper.GetDataSet(sql);
            ds.Tables[0].TableName = "used_infotype";
            ds.Tables[1].TableName = "used_infotype2";
            DataColumn Parent = ds.Tables["used_infotype"].Columns["id"];
            DataColumn Child = ds.Tables["used_infotype2"].Columns["superid"];
            DataRelation trelation = new DataRelation("trelation", Parent, Child, false);
            ds.Relations.Add(trelation);
            Repeater3.DataSource = ds.Tables["used_infotype"].DefaultView;      
            Repeater3.DataBind();

    页面代码:

     <asp:Repeater ID="Repeater3" runat="server">
                    <ItemTemplate>
                                  <%# Eval("typename") %>
                      <div style="border-bottom:1px solid #ff0000; height:1px; overflow:hidden; 100%"></div>
                        <asp:Repeater ID="Repeater4" runat="server" DataSource='<%#((System.Data.DataRowView)Container.DataItem).CreateChildView("trelation")%>' DataMember="superid">
                        <ItemTemplate>
                        <%# Eval("typename") %>

                        </ItemTemplate>
                        <SeparatorTemplate>
                        |
                        </SeparatorTemplate>
                        </asp:Repeater>               
                      <br />
                 
                    </ItemTemplate>
                    </asp:Repeater>

  • 相关阅读:
    Vim
    一文搞定Samba云服务器配置(阿里云)CentOS8.3
    第四课 婴儿是如何思考的 思维的发展历程
    C++/VS基础篇
    Windows下Qt VS 打包程序 到他人电脑安装运行出现的问题
    第三课 斯金纳
    第二课基础 弗洛伊德
    C++中头文件和实现文件的关系
    字符串 数字 转换
    Ucore lab1实验报告
  • 原文地址:https://www.cnblogs.com/kiwifruit/p/1863148.html
Copyright © 2011-2022 走看看