Repeater: Items.count in ItemDataBound Event

J

Josh Daws

Hi,

I'm just learning asp.net. I'm very familiar with asp and coldfusion, but
I'm getting very frustrated learning asp.net. I'm working on my first
project. Basically just converting a coldfusion site to asp.net

Here's what I need to do. I have a repeater that is displaying a list of
records from the db. I need the first item and the last item displayed to
be designated as first and last. Is this possible? I know I can use
e.item.itemIndex for the current record so that takes care of the first
record, but how can I tell when the item is the last item of the repeater?

Thanks.

--

Josh Daws
428 Productions, Inc.
(770) 867-8517
www.428Productions.com

Visit www.TwoBySea.net for creative gift ideas!
 
A

Ather Ali Shaikh

you can use this line

myRepeater.Items.Count

it is a zero based indexing

that your last item will be at "Count - 1"

Regards
Ather Ali Shaikh
 
Joined
Sep 11, 2006
Messages
1
Reaction score
0
Check the size of the datasource

You can also try something like this:

if (e.Item.ItemIndex == ((ProductCollection)rptProducts.DataSource).Count-1)
//here you can do something with the last item


In other words: you can always check the size of the DataSource that you are binding to the repeater, and that way find out the last item in the repeater.


///Claes
 

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

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top