Have you overridden DataBind method to recreate child controls?
Something like:
public override void DataBind()
{
ChildControlsCreated = false;
CreateChildControls();
ChildControlsCreated = true;
base.DataBind();
}
You don't also need to check ChildControlsCreated in CreateChildControls,
calling EnsureChildControls will do that. And in CreateChildControls the
first line should be Controls.Clear();
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"cmartinbot" <> wrote in message
news: ups.com...
> Hello and TIA.
>
> I have a very simple server control that has one property that needs
> to be rendered in an ITemplate. I can't seem to figure out why it
> won't render with the <%# Container.Value%> syntax inside the
> declarative template.
>
> The container control for the template is being instantiated
> correctly.
>
> It should be said that this control lives within a Repeater
> ItemTemplate which I suspect is the reason for this not working.
>
> Relative Code:
> ---
>
> [ParseChildren(true)]
> public class CustomData : WebControl, INamingContainer
> {
> private ITemplate content;
> private string currentValue;
>
> protected override void CreateChildControls()
> {
> if( !ChildControlsCreated )
> {
> IDataRetriever retriever = DataRetriever.Create(dataType, article,
> forceFetch, label);
>
> currentValue = retriever.ValueString;
>
> InstantiateTemplate(content);
>
> ChildControlsCreated = true;
> }
> }
>
> private void InstantiateTemplate(ITemplate template)
> {
> if(template == null)
> {
> template = new DefaultTemplate( currentValue );
> }
>
> DataContainer container = new DataContainer(currentValue);
> template.InstantiateIn(container);
> Controls.Add( container );
> }
>
> #region Properties
>
> [PersistenceMode( PersistenceMode.InnerProperty )]
> [TemplateContainer(typeof(DataContainer))]
> [Browsable(false)]
> public ITemplate Content
> {
> get { return content; }
> set { content = value; }
> }
>
> #endregion
> }
> }
>
> public class DataContainer : Control, INamingContainer
> {
> private string value;
>
> public DataContainer(string value)
> {
> this.value = value;
> }
>
> public string Value
> {
> get { return value; }
> set { this.value = value; }
> }
> }
>
> ASPX:
> ---
> <cc1:CustomData ID="CustomData2" DataType="ShortString" runat="server"
> Label="City">
> <Content>(CityIsHereButNotShowing[<%# Container.Value%>])</Content>
> </cc1:CustomData>
>
> Please help!!!
>
> Thanks again,
> Chris Martin
>