Repeater
The Repeater component is meant to emulate the asp:Repeater control in markup and is defined in the System.Web.UI.WebControls.Repeater class
Web Forms Declarative Syntax¶
<asp:Repeater
DataMember="string"
DataSource="string"
DataSourceID="string"
EnableTheming="True|False"
EnableViewState="True|False"
ID="string"
OnDataBinding="DataBinding event handler"
OnDisposed="Disposed event handler"
OnInit="Init event handler"
OnItemCommand="ItemCommand event handler"
OnItemCreated="ItemCreated event handler"
OnItemDataBound="ItemDataBound event handler"
OnLoad="Load event handler"
OnPreRender="PreRender event handler"
OnUnload="Unload event handler"
runat="server"
Visible="True|False"
>
<AlternatingItemTemplate>
<!-- child controls -->
</AlternatingItemTemplate>
<FooterTemplate>
<!-- child controls -->
</FooterTemplate>
<HeaderTemplate>
<!-- child controls -->
</HeaderTemplate>
<ItemTemplate>
<!-- child controls -->
</ItemTemplate>
<SeparatorTemplate>
<!-- child controls -->
</SeparatorTemplate>
</asp:Repeater>
Usage Notes¶
- ItemType attribute - Required to specify the type of items in the collection
- Context attribute - For Web Forms compatibility, use
Context="Item"to access the current item as@Itemin templates instead of Blazor's default@context - ID - Use
@refinstead ofIDwhen referencing the component in code - runat and EnableViewState - Not used in Blazor (these attributes are ignored)
Blazor Example¶
<Repeater Items="products" ItemType="Product" Context="Item">
<HeaderTemplate>
<h2>Product List</h2>
</HeaderTemplate>
<ItemTemplate>
<div class="product">@Item.Name - $@Item.Price</div>
</ItemTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
<FooterTemplate>
<p>End of list</p>
</FooterTemplate>
</Repeater>