this is my scenario:
i have a page with a placeholder. the page adds dynimcally different kinds of controls (we wan't to display some data - getting the id via querystring or postback, as we also have a tree) to this placeholder.
the added controls all, more or less, contain a textbox (name of the displaying element), checkbox (active-state of the displaying element) and a save-button which fires a method inside this webcontrol.
now my problem is really obvious: as i'm adding the control dynamically (and for every condition: !Postback and Postback), the save-method inside the so added control, won't fire - regardless what i do ...
i'm simply to stupid to get the trick :)
some behind-the-scene-infos (workflow):
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
this.SelectedElement = SomeMagicMethod();
}
}
protected void NodeSelected(object sender, TreeViewNodeEventArgs e)
{
this.SelectedElement = SomeOtherMagicMethod();
}
protected override void OnLoadComplete(EventArgs e)
{
// we have to take this life-cycle!
if (this.SelectedElement!= null)
{
this.DisplayElement();
}
}
private void DisplayElement()
{
var UC = this.LoadControl(UCPath) as DataTypeUC;
if (UC == null)
{
return;
}
UC.ID = EditCampaignFolderUCID;
UC.SetData(this.SelectedElement);
UC.DataBind();
this.phContent.Controls.Add(UC);
}