分析器错误信息: 类型“System.Web.UI.WebControls.Repeater”不具有名为“template”的属性。 源错误: 行 116: <template name=HeaderTemplate> <!--源文件:form\ServerControl\FormRepeater.aspx-->
<html>
<head>
<script language="vb" runat=server>
Class Leader
'定义一个类Leader
dim strCountry as String
dim strName as String
Public Sub New(country As String, name As String)
MyBase.New
strName = name
strCountry= country
End Sub
ReadOnly Property Name As String
Get
Return strName
End Get
End Property
ReadOnly Property Country As String
Get
Return strCountry
End Get
End Property
End Class
sub Page_Load(s as object,e as eventargs)
dim leaders as ArrayList = New ArrayList()
if Not Page.IsPostBack
'加载数据
leaders.add(new leader("美利坚","布 什"))
leaders.add(new leader("俄罗斯","普 京"))
leaders.add(new leader("中 国","***"))
Repeater1.DataSource=leaders
Repeater2.DataSource=leaders
Repeater1.DataBind
Repeater2.DataBind
end if
end sub
</script>
<title>
重复列表使用例子
</title>
</head>
<center>
<h2>重复列表的使用</h2>
<hr>
<br>
'以表格形式显示国家,领导人信息
<asp:Repeater id="Repeater1" runat=server>
'定义表头
<template name=HeaderTemplate>
<table border=2>
<tr>
<th>
国家名
</th>
<th>
领导人
</th>
</tr>
</template>
'定义数据显示格式
<template name=ItemTemplate>
<tr>
<td>
<%# DataBinder.Eval(Container.DataItem,"Country") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem,"Name") %>
</td>
</tr>
</template>
'定义表尾
<template name=FooterTemplate>
<tr>
<td>日期</td>
<td>2001年</td>
</tr>
</table>
</template>
</asp:Repeater>
<br>
<asp:Repeater id=Repeater2 runat=server>
'国家和领导人以|分割显示
<template name=ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"Country") %>
---
<%# DataBinder.Eval(Container.DataItem,"Name") %>
</template>
<template name=SeparatorTemplate>
|
</template>
</asp:Repeater>
</center>
</body>
<html>