numbering a repeater rows

a8le

Well-known member
Joined
Oct 27, 2005
Messages
75
Programming Experience
5-10
hi all,

is there a simple way to number repeater rows? for example my repeater displays....

comments on a blog...

comment one
comment two
comment three
etc...

i want it to be...

1) comment one
2) comment two
3) comment three and so forth

i would appreciate any advice, thanx in advance.

-a8le
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,439
Location
Norway
Programming Experience
10+

a8le

Well-known member
Joined
Oct 27, 2005
Messages
75
Programming Experience
5-10
hi JohnH,

where is exactly did you see that...
HTML:
<%#Container.ItemIndex%>
i can't find it... its not on that page or the other properties pages.

by the way, i got it to work. thnx for the help.

-a8le
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,439
Location
Norway
Programming Experience
10+
Actually I didn't find the reference for Container.ItemIndex either, I saw Container.DataItem in that example and just inspected the Container object and it's properties in the intellitype editor.
 

venky

Active member
Joined
Sep 12, 2005
Messages
27
Programming Experience
1-3
Try this it will work at the same time give the result which fashion you need

<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, e As EventArgs)

If Not IsPostBack Then
Dim values As New ArrayList()

values.Add("Apple")
values.Add("Orange")
values.Add("Pear")
values.Add("Banana")
values.Add("Grape")

Repeater1.DataSource = values
Repeater1.DataBind()

End If
End Sub

</script>

</head>
<body>

<h3>Repeater Example</h3>

<form runat=server>

<b>Repeater1:</b>
<p>

<asp:Repeater id=Repeater1 runat="server">

<HeaderTemplate>
<table border=1>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td>
<%# Container.ItemIndex+1 %>
<%# Container.DataItem %>
</td>
</tr>

</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Repeater>

<p>

</form>
</body>
</html>
 
Top Bottom