How to count the number of items in a repeater using ASP.NET?
I would like to display something along the lines of:
MARKUP
Page 1 of 5
ASPX
Get Item Index: (working)
<%# DataBinder.Eval(Container, "ItemIndex", "") + 1%>
Count total items: (failing)
<%# DataBinder.Eval(Container.ItemIndex, rpt.Items.Count)%>
I would prefer to do this on page however am open to suggestions and code behind.
This is the best solution I get it
<asp:Repeater ID="rptGallery" runat="server" >
<ItemTemplate>
<div>
<div>
<asp:Label ID="Number_of_element_in_repeater" runat="server"
Text='<%#Convert.ToString(((IList((Repeater)Container.Parent).DataSource).Count) %>'>
</asp:Label>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
The number of items in repeater is:
Convert.ToString(((IList)((Repeater)Container.Parent).DataSource).Count)