惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
B
Blog
博客园_首页
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog RSS Feed
M
MIT News - Artificial intelligence
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
量子位
V
V2EX
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - Blog
Martin Fowler
Martin Fowler
Recent Announcements
Recent Announcements
I
InfoQ
博客园 - 【当耐特】

博客园 - Caesar

t-sql中的随机数 服务器应用程序不可用[解决办法] 配置错误:未能使用提供程序“RsaProtectedConfigurationProvider”进行解密。提供程序返回错误信息为: 打不开 RSA 密钥容器。 让指定的按钮获取文本框的回车键 正则表达式的语法表 JS几种常用的表单判断 .aspx中写的Page_Load不执行 安装VS2005 SP1补丁方法(转) 读取Cookie出现乱码的解决办法. 数据库的备份与恢复 ASP.NET基于角色的窗体安全认证机制 用Ajax读取Text格式的数据(转) JQuery参考文档 asp.net过滤HTML标签的几个函数 验证日期的正则表达式 去掉所有HTML标记 将GridView中内容导入到Word asp.net中使用javascript C#文件操作
ASP.NET 嵌套Repeater
Caesar · 2008-01-05 · via 博客园 - Caesar

以下是引用片段:
  -----
Nestedrepeater.aspx

<%@ Page language="c#" Codebehind="NestedRepeater.aspx.cs" AutoEventWireup="false" Inherits="NestedRepeater.NestedRepeater" %>
            <%@ Import Namespace="System.Data" %>
            <html>
            <body>
            <form runat=server>
            <!-- start parent repeater -->
            <asp:repeater id="parentRepeater" runat="server">
            <itemtemplate>
            <b><%# DataBinder.Eval(Container.DataItem,"au_id") %></b><br>
            <!-- start child repeater -->
            <asp:repeater id="childRepeater" datasource='<%# ((DataRowView)Container.DataItem)
            .Row.GetChildRows("myrelation") %>' runat="server">
            <itemtemplate>
            <%# DataBinder.Eval(Container.DataItem, "[\"title_id\"]")%><br>
            </itemtemplate>
            </asp:repeater>
            <!-- end child repeater -->
            </itemtemplate>
            </asp:repeater>
            <!-- end parent repeater -->
            </form>
            </body>
            </html>
            

Nestedrepeater.aspx.cs

using System;
            using System.Data;
            using System.Data.SqlClient;
            using System.Web;
            using System.Web.SessionState;
            using System.Web.UI;
            using System.Web.UI.WebControls;
            namespace NestedRepeater
            {
            public class NestedRepeater : System.Web.UI.Page
            {
            protected System.Web.UI.WebControls.Repeater parentRepeater;
            public NestedRepeater()
            {
            Page.Init += new System.EventHandler(Page_Init);
            }
            public void Page_Load(object sender, EventArgs e)
            {
            //Create the connection and DataAdapter for the Authors table.
            SqlConnection cnn = new SqlConnection("server=(local);database=pubs; Integrated Security=SSPI ;");
            SqlDataAdapter cmd1 = new SqlDataAdapter("select * from authors",cnn);
            //Create and fill the DataSet.
            DataSet ds = new DataSet();
            cmd1.Fill(ds,"authors");
            //Create a second DataAdapter for the Titles table.
            SqlDataAdapter cmd2 = new SqlDataAdapter("select * from titleauthor",cnn);
            cmd2.Fill(ds,"titles");
            //Create the relation bewtween the Authors and Titles tables.
            ds.Relations.Add("myrelation",
            ds.Tables["authors"].Columns["au_id"],
            ds.Tables["titles"].Columns["au_id"]);
            //Bind the Authors table to the parent Repeater control, and call DataBind.
            parentRepeater.DataSource = ds.Tables["authors"];
            Page.DataBind();
            //Close the connection.
            cnn.Close();
            }
            private void Page_Init(object sender, EventArgs e)
            {
            InitializeComponent();
            }
            private void InitializeComponent()
            {
            this.Load += new System.EventHandler(this.Page_Load);
            }
            }
            }