| ||||||||||||||
Repeater Control SyntaxASP.NET Syntax ASP.NET Syntax for Web Controls A data-bound list control that allows custom layout by repeating a specified template for each item displayed in the list. For information on the individual members of this class, see Repeater in the class library. RemarksThe Repeater control renders a basic templated data-bound list. The Repeater control has no built-in layout or styles; you must explicitly declare all HTML layout, formatting, and style tags within the control's templates. The following table lists the different templates of the Repeater control.
The Repeater control has no built-in selection or editing support. You can, however, define a handler for the control's ItemCommand event to process control events that are sent from the templates to the control. The control binds its Item and AlternatingItem templates to a data structure referenced in the control's DataSource property. If the DataSource property is not set, the Repeater control is not rendered. If the DataSource is set but no data is returned, the control renders the Header and Footer templates, with no items. Syntax ExampleThe Repeater control is different from other data list controls in that it allows you to place HTML fragments in its templates. This allows you to create a complex HTML structure, such as a table. The following example illustrates use of a Repeater control.
The sample is implemented basically as follows:
<body>
<asp:repeater id="myRepeater" runat="server">
<headertemplate>
<table width = "100%" cellspacing=1 cellpadding=3 style = "font:8pt verdana">
<tr style = "background-color:#ddc">
<th>Title</th>
<th>Title ID</th>
<th>Type</th>
<th>Publisher ID</th>
<th>Price</th></tr>
</headertemplate>
<itemtemplate>
<tr style = "background-color:whitesmoke; height:17pt">
<td><%# DataBinder.Eval ( Container.DataItem, "title" ) %></td>
<td><%# DataBinder.Eval ( Container.DataItem, "title_id" ) %></td>
<td><%# DataBinder.Eval ( Container.DataItem, "type" ) %></td>
<td><%# DataBinder.Eval ( Container.DataItem, "pub_id" ) %></td>
<td><%# DataBinder.Eval ( Container.DataItem, "price", "{0:c2}" ) %></td></tr>
</itemtemplate>
<footertemplate>
</table>
</footertemplate>
</asp:repeater>
</body>
See AlsoRepeater Class Repeater Web Server Control |
| |||||||||||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme