利用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>
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步