J
J055
Hi
I need to access multiple instances of the same UserControl dynamically. I
can successful do this with one control but I'm not sure how I can assign
multiple instances to a Repeater at runtime.
This is what I have so far
protected void Page_Init(object sender, EventArgs e)
{
// load the account finder control
_accountFinder =
(AccountFinder)LoadControl("~/Controls/AccountFinder.ascx");
}
//This is called multiple times by a Repeater control
//I need to be able to add a new instance of the control if the PlaceHolder
is visible
protected void phIndividualsFinder_Load(object sender, EventArgs e)
{
PlaceHolder phIndividualsFinder = (PlaceHolder)sender;
// made visible by the click event on a previous postback
if (phIndividualsFinder.Visible == true)
{
phIndividualsFinder.Controls.Add(_accountFinder);
}
}
What is the correct way of achieving this? Many thanks
Andrew
I need to access multiple instances of the same UserControl dynamically. I
can successful do this with one control but I'm not sure how I can assign
multiple instances to a Repeater at runtime.
This is what I have so far
protected void Page_Init(object sender, EventArgs e)
{
// load the account finder control
_accountFinder =
(AccountFinder)LoadControl("~/Controls/AccountFinder.ascx");
}
//This is called multiple times by a Repeater control
//I need to be able to add a new instance of the control if the PlaceHolder
is visible
protected void phIndividualsFinder_Load(object sender, EventArgs e)
{
PlaceHolder phIndividualsFinder = (PlaceHolder)sender;
// made visible by the click event on a previous postback
if (phIndividualsFinder.Visible == true)
{
phIndividualsFinder.Controls.Add(_accountFinder);
}
}
What is the correct way of achieving this? Many thanks
Andrew