Repeater控件嵌套,测试通不过

sunnystroller sunnystroller 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
借鉴:
http://dev.csdn.net/develop/article/29/29697.shtm

就是通不过

//************************************************************************
<%@ Page language="c#" Codebehind="testaspx.aspx.cs" AutoEventWireup="false" Inherits="Tonglang.testaspx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>testaspx</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">
<FONT face="宋体">
<!-- start parent repeater -->
<asp:repeater id="parent" runat="server">
<itemtemplate>
<b>
<%# DataBinder.Eval(Container.DataItem,"au_id") %>
</b>
<br />
<!-- start child repeater -->
<asp:repeater id="child" 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 -->
</FONT>
</form>
</body>
</HTML>
//************************************************************************
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Tonglang
{
/// <summary>
/// testaspx 的摘要说明。
/// </summary>
public class testaspx : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Repeater parent;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
//Create the connection and DataAdapter for the Authors table.
SqlConnection cnn = new SqlConnection("server=(local);database=pubs;uid=sa;pwd=sa;");
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.
parent.DataSource = ds.Tables["authors"];
Page.DataBind();



//Close the connection.
cnn.Close();
}

#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
}
}
报错如下:

编译器错误信息: CS0246: 找不到类型或命名空间名称“DataRowView”(是否缺少 using 指令或程序集引用?)

真是奇怪,我看了好多相关的资料都是这样写的,孟兄的我也看了,http://dotnet.aspx.cc/ShowDetail.aspx?id=54F4C732-AAE2-4135-FB1B-7B4B613BAA33

我没有发现我有什么错误,怎么就是通不过啊?
请高手指点!谢谢!!

...全文
评论 1
收藏 已收藏
分享
返回顶部
sunnystroller
.NET社区 62,274 成员 668,968 内容