ASP.Net User Control Template Instantiation
- by Chris
Hi,
I created a user control that has a template container.
<cc:SearchResultItem ID="SearchResultItem1" Customer='<%# ((Customer)(((RepeaterItem)Container).DataItem)) %>' runat="server">
<NameTemplate>
<%# Container.Name %>
</NameTemplate>
</cc:SearchResultItem>
This is control is placed in a repeater which lists some customers. The customer is than bound to the user control. When the name template is instantiated in the container, the customer object is not yet available, but I need to access its name because it needs to get parsed before.
protected void Page_Init(object sender, EventArgs e)
{
if (nameTemplate != null )
{
// customer is null here, it is avaiable only after Page_Init...
NameContainer container = new NameContainer(customer.Id, Parse(customer.Name));
nameTemplate.InstantiateIn(container);
placeHolder.Controls.Add(container);
}
}
Question: How can I access properties set for the user control BEFORE the template container is instantiated? Thanks in advance!