</itemtemplate>
</asp:repeater>
<!-- 子Repeater结束 -->
</itemtemplate>
</asp:repeater>
<!-- 父Repeater结束 -->
</form>
</body>
</HTML>
----------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class NestedRepeater : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Repeater parentRepeater;
private void Page_Load(object sender, System.EventArgs e)
{
// 为Authors表创建 Connection 和 DataAdapter
string cnnString = @"server=(local);database=pubs; uid=sa;pwd=sa;";
SqlConnection cnn = new SqlConnection(cnnString);
SqlDataAdapter cmd1 = new SqlDataAdapter("select * from authors",cnn);
DataSet ds = new DataSet();
cmd1.Fill(ds,"authors");
SqlDataAdapter cmd2 = new SqlDataAdapter("select * from titleauthor",cnn);
cmd2.Fill(ds,"titles");
ds.Relations.Add("myrelation",
ds.Tables["authors"].Columns["au_id"],
ds.Tables["titles"].Columns["au_id"]);
parentRepeater.DataSource = ds.Tables["authors"];
parentRepeater.DataBind();
cnn.Dispose();
/*
use pubs
where a.au_id=b.au_id
order by 1
*/
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}