Initialization of a Web User Control inside Repeater Control

S

satyajit

I am working on an application that has a Web User Control contained
within <ItemTemplate> of a Repeater control. The Web User Control has
a public property that needs to be assigned in order to work correctly
(the web user control uses this object to initialize DataSource of
some of its child controls). Is it correct to use Repeater's
ItemCreated event to assign value to the above mentioned public
property? If not, what are the alternatives?

I also want to know at which stage of life-cycle of the contained Web
User Control, the ItemCreated event of the repeater control will be
invoked?
 
C

Cowboy \(Gregory A. Beamer\)

Or you can expose a public (or internal?) property on the user control and
set it using the normal Eval() to pull data and set the property with it.
Provided, of course, the setting is in the data you are binding to the
repeater.

When you think of user controls as black boxes, much like other controls,
you find you can treat them the same way.
 
S

satyajit

Or you can expose a public (or internal?) property on the user control and
set it using the normal Eval() to pull data and set the property with it.
Provided, of course, the setting is in the data you are binding to the
repeater.

okay.

However, if for some reason, it's not possible to do it in the markup,
we would need to use ItemCreated event. Correct?
When you think of user controls as black boxes, much like other controls,
you find you can treat them the same way.

My trouble is that the user control has used the property (in
question) in its OnInit event. Is it guaranteed that OnInit of user
control will be called after ItemCreated event of parent repeater
control? This is not clear in MSDN documentation for "ASP.NET Page
Life Cycle Overview" <http://msdn2.microsoft.com/en-us/library/
ms178472.aspx>.

Thanks.
- Satyajit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top