Calculate the repeater elements that are in the user control and display it in the literal format that is on the page?

I have a scenario in which I want to calculate the number of entries in a repeater that is in a user control and display the count in a literal that is on the page (ex default.aspx). How can i achieve this? I do not want to use public properties .... I want to do this by creating my own custom event.

Any help or suggestion would be greatly appreciated.

Thank Sumit Arora

+3
source share
1 answer

Create a property in the user control:

public int NumberOfRecords { get { return myRepeater.Items.Count; } }

Then in Page_Load:

countLabel.Text = string.Format("Number of records: {0}", myUserControl.NumberOfRecords);
+1

Source: https://habr.com/ru/post/1754218/


All Articles