利用Repeater控件显示主-从关系数据表 (NestedRepeater.aspx)

<%@ Import Namespace="System.Data" %>NestedRepeater.aspx

<%@ Import Namespace="System.Data" %>

<%@ Page language="c#" Codebehind="NestedRepeater.aspx.cs" AutoEventWireup="false" Inherits="SNHY.NestedRepeater" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>NestedRepeater</title>
  <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
  <meta name="CODE_LANGUAGE" Content="C#">
  <meta name="vs_defaultClientScript" content="JavaScript">
  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
 </HEAD>
 <body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">
  <asp:repeater id="Repeater1" runat="server">
  <itemtemplate>
   <b>
   <%# DataBinder.Eval(Container.DataItem,"CID") %>
   </b>
   <br>
   <!-- 子Repeater开始 -->
   <asp:repeater id="childRepeater" runat="server"
   datasource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("myrelation") %>'>
   <itemtemplate>
    <%# DataBinder.Eval(Container.DataItem, "[\"CTitle\"]")%>
    <br>
   </itemtemplate>
   </asp:repeater>
   <!-- 子Repeater结束 -->
  </itemtemplate>
  </asp:repeater>
  </form>
 </body>
</HTML>

posted @ 2006-01-04 18:46  接云网络  阅读(322)  评论(0编辑  收藏  举报