getting rowcount from within a repeater control


D

Darrel

I'm working on an asp.net 1.1 app and trying to put as much output as I can
into repeater controls to let the client later modify the HTML.

I'm stuck on how to add the rowcount to a repeater. I have a need to put the
item # in the HTML (ie, row 0 needs to output a 0 to the HTML, row 1 needs
to putput a 1, etc.)

Is there a way to get the rowcount of the data from within the control?
Something like DataBinder.Eval.GetRowCount (which I know does not exis). Or
should this be handled via the SQL query itself and create a field in the
dataset? Another method?

-D
 
Ad

Advertisements

S

Steve S

Hi Darrel,
try using Container.ItemIndex, see example below.

<asp:Repeater ID="testRepeater" runat="server">
<ItemTemplate>
<asp:Label ID="name" Text='<%# Eval("Name") %>'
runat="server" /><br>
<asp:Label ID="itemIndex" Text='<%# Container.ItemIndex %>'
runat="server" /><br>
</ItemTemplate>
</asp:Repeater>

Cheers
SteveS
 
Ad

Advertisements

D

Darrel

try using Container.ItemIndex, see example below.

That's exactly it!

Thanks!

-Darrel
 

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

Top