Repeater Control Counting Items
-
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
-
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
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
-
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
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, theRepeater.Items.Count
just gives you the number of theRepeaterItem
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. -
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, theRepeater.Items.Count
just gives you the number of theRepeaterItem
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.Better yet :-D daniero