asp.net(C#) Repeater 控件,重复内容(无默认html,高度可自定义化)
时间:2011-04-13 来源:hen
<HeaderTemplate>
元素中的内容在输出中仅出现一次
<ItemTemplate>
元素的内容会对应 DataSet 中的 "record" 重复出现
<FooterTemplate>
的内容在输出中仅出现一次
<AlternatingItemTemplate>
您可以在 <ItemTemplate> 元素后添加 <AlternatingItemTemplate> 元素,这样就可以描述交替行的外观了。
<SeparatorTemplate>
元素能够用于描述每个记录之间的分隔符。比分隔符直接写在<ItemTemplate>标签 会在结尾少一个分割符;
数据绑定
<%#Container.DataItem("fieldname")%> fieldname 表示 列名
例子:
<form runat="server">
<asp:Repeater id="cdcatalog" runat="server">
<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>Title</th>
<th>Artist</th>
<th>Country</th>
<th>Company</th>
<th>Price</th>
<th>Year</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Container.DataItem("title")%></td>
<td><%#Container.DataItem("artist")%></td>
<td><%#Container.DataItem("country")%></td>
<td><%#Container.DataItem("company")%></td>
<td><%#Container.DataItem("price")%></td>
<td><%#Container.DataItem("year")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
相关阅读 更多 +










