Hi
How to get the count of rows in a repeater
Thanks
Hi
How to get the count of rows in a repeater
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh KumarPosted Jun 12, 2023, 3:46 AM
Hello Raco,
You can do using two way,
OR
Prasad RaveendranPosted Jun 12, 2023, 1:57 AM
In your ASP.NET markup file (e.g., .aspx), define a repeater control and assign it an ID:
In your code-behind file (e.g., .aspx.cs), you can access the repeater control and retrieve the row count using the
Repeater.Items.Countproperty:In this example, the Page_Load event handler is used to bind data to the repeater (if necessary) and retrieve the row count using the myRepeater.Items.Count property. You can then use the row count for further processing or display, such as assigning it to a label (YourLabel.Text) to show it to the user.
Remember to replace YourDataSource with your actual data source and adjust the item template markup according to your requirements.
Ramco RamcoPosted Jun 11, 2023, 4:44 PM
Hi
Do we need to subtract 1 from repeater1.Items.Count
Thanks
Amira BedhiafiPosted Jun 11, 2023, 12:10 PM
You can access the number of items in the repeater's data source by using the
Itemsproperty and then getting the count of the collection :int rowCount = repeater1.Items.Count;
If you are manually populating the repeater control without using a data source, you can still get the count by accessing the
Itemsproperty and getting the count of the items.int rowCount = repeater1.Items.Count;