I am creating a repeater dynamically in code behind. I then want to execute the OnItemDataBound event when the DataBind() method is invoked, like this:
Dim Repeater1 As New Repeater()
Repeater1.DataSource = dataSource
Repeater1.OnItemDataBound = "Repeater1_OnItemDataBound"
Repeater1.DataBind()
The compiler tells me the function OnItemDataBound is not accessible in this context because it is ‘Protected’
I’m creating a dynamic repeater because the number of columns it needs depends on the data in the data source.
How do I execute my ItemDataBound code for each item in the data source when the DataBind method is invoked?
You probably want to add an event handler, then you need to use the
AddHandlerstatement:Of course the method must be accessible, normally it is in the same class: