Repeater: Items.count in ItemDataBound Event

Discussion in 'ASP .Net' started by Josh Daws, Jan 16, 2004.

  1. Josh Daws

    Josh Daws Guest

    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!
    Josh Daws, Jan 16, 2004
    #1
    1. Advertising

  2. 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

    "Josh Daws" <> wrote in message news:YjXNb.2229$...
    > 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!
    >
    >
    >
    >
    Ather Ali Shaikh, Jan 17, 2004
    #2
    1. Advertising

  3. Josh Daws

    Claes

    Joined:
    Sep 11, 2006
    Messages:
    1
    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
    Claes, Sep 11, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. René Paschold

    Re: ItemDataBound in Repeater: FYI

    René Paschold, Oct 14, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    407
    René Paschold
    Oct 16, 2003
  2. =?Utf-8?B?S2V2aW4gSGVjdG9y?=

    Repeater ItemCreated vs ItemDataBound

    =?Utf-8?B?S2V2aW4gSGVjdG9y?=, Apr 11, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    9,893
    Teemu Keiski
    Apr 11, 2004
  3. GaryDean
    Replies:
    1
    Views:
    8,676
    Walter Wang [MSFT]
    Aug 18, 2006
  4. SushiSean

    ItemDataBound event for Repeater

    SushiSean, Jan 8, 2008, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    2,399
  5. NH
    Replies:
    2
    Views:
    516
    Andrew L. Van Slaars
    Dec 17, 2004
Loading...

Share This Page