Perte d'un UserControl chargé dynamquement après un PostBack
Bonjour
Dans mon formulaire, j'ai une DropDownList qui contient une liste de valeur de 1 à 10.
Lorsque je sélectionne un nombre dans la DropDownList, je charge dans un PlaceHolder autant de UserControl que la valeur de la DropDownList.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| string sID = "";
int iNbCondSuppl = 0;
int.TryParse(this.ddlNbCondSuppl.SelectedValue, out iNbCondSuppl);
for (int i = 1; i <= iNbCondSuppl; i++)
{
sID = "uscCondSuppl" + i.ToString("00");
if (plhCondSuppl.FindControl(sID) == null)
{
// Ajout dynamique du UserControl
Usc_ucConducteurDesigneTable uc = (Usc_ucConducteurDesigneTable)LoadControl("~/Usc/ucConducteurDesigneTable.ascx");
uc.ID = sID;
plhCondSuppl.Controls.Add(uc);
}
} |
Mon problème, c'est que lorsqu'il y a un AutoPostBack, je perds mes userControl.
Merci du coup de pouce
Titan