Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Repeater Control Counting Items

Repeater Control Counting Items

Scheduled Pinned Locked Moved ASP.NET
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RadioButton
    wrote on last edited by
    #1

    Hello, How does one count the Items in a Repeater control. I noticed the repeater does not give you a single value count using Repeater.Items.Count. So I tried: void Repeater_ItemCreated(Object Sender, RepeaterItemEventArgs e) { itemCount++; Response.Write("" + itemCount.ToString() + ""); } and I get "234567891011" for itemCount. What is the trick I am missing. Thanks for the help. RadioB

    D M 2 Replies Last reply
    0
    • R RadioButton

      Hello, How does one count the Items in a Repeater control. I noticed the repeater does not give you a single value count using Repeater.Items.Count. So I tried: void Repeater_ItemCreated(Object Sender, RepeaterItemEventArgs e) { itemCount++; Response.Write("" + itemCount.ToString() + ""); } and I get "234567891011" for itemCount. What is the trick I am missing. Thanks for the help. RadioB

      D Offline
      D Offline
      Daniel Santillanes
      wrote on last edited by
      #2

      Hi RB, You don't need to manually count the rows in the Repeater, you are binding from a collection / array / datatable right? you only need to access the collection's .Count or .Length property and that's it :). I hope this is enough information, if not, let us know. daniero

      1 Reply Last reply
      0
      • R RadioButton

        Hello, How does one count the Items in a Repeater control. I noticed the repeater does not give you a single value count using Repeater.Items.Count. So I tried: void Repeater_ItemCreated(Object Sender, RepeaterItemEventArgs e) { itemCount++; Response.Write("" + itemCount.ToString() + ""); } and I get "234567891011" for itemCount. What is the trick I am missing. Thanks for the help. RadioB

        M Offline
        M Offline
        minhpc_bk
        wrote on last edited by
        #3

        Hi there, What you are doing is simply to count how many times the event handler of the ItemCreated event is called. Basically, this event gets fired when an item (header, item, alternating item, seperator, footer) is created in the control. Meanwhile, the Repeater.Items.Count just gives you the number of the RepeaterItem items in the control, and it does not include the header, footer. This value is equal to size of the datasource which is bound to the repeater control.

        D 1 Reply Last reply
        0
        • M minhpc_bk

          Hi there, What you are doing is simply to count how many times the event handler of the ItemCreated event is called. Basically, this event gets fired when an item (header, item, alternating item, seperator, footer) is created in the control. Meanwhile, the Repeater.Items.Count just gives you the number of the RepeaterItem items in the control, and it does not include the header, footer. This value is equal to size of the datasource which is bound to the repeater control.

          D Offline
          D Offline
          Daniel Santillanes
          wrote on last edited by
          #4

          Better yet :-D daniero

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups