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

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top