Item number in datarepeater

G

Guest

I have a datarepeater.
<asp:Repeater id="_quiestionsDataRepeater" runat="server"> <ItemTemplate>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<asp:Label id="Label2" runat="server">Label</asp:Label>
</td>
</tr>
</table>
<ItemTemplate>
</asp:Repeater >

It could have multiple rows based on the data. I like to write the sequnce
number of row before the Label2. So if its first row of data I would like 1
to be preceeding the label content and 2 for the second and hence forth....

How can I do that?

Thnx in advance.
 
E

Eliyahu Goldin

Add another cell with a label control to the table in the ItemTemplate.
Handle the repeater's PreRender event. In the event handler loop through the
Items collection. For every item find the label and set it's text into the
loop index.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top