Bonjour,
je vais encore sollicité l'aide du forum ...
Je vous explique mon problème.
Je possède une page sur laquelle il y a une TextBox et deux boutons.
Lorsque je clique sur le premier bouton, il y a la création de N Panels (N étant le chiffre entré dans la TextBox).
Dans ces panels, je crée des TextBox, labels et DropDownList.
Mon soucis est le suivant, les panels se créent comme voulu, mais seulement, je n'arrive pas à valider le formulaire ainsi créé avec mon deuxième bouton.
Je veux dire par valider, je n'arrive pas à récupérer les informations des TextBox et DropDownList que j'ai précédament créé.
Ci-joint le code de création des panels.
Voici le code du second bouton :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132 protected void btnAjoutPH_Click(object sender, EventArgs e) { if (Page.IsPostBack) { Label monLabel = null; TextBox maTextBox = null; DropDownList maDrop = null; RequiredFieldValidator monValidateur = null; for (int i = 0; i < Convert.ToInt32(TextBox3.Text); i++) { nbPhoto++; monPanel = new Panel(); // Le panel que je veux ajouter monPanel.ID = "Photo" + nbPhoto.ToString(); monPanel.GroupingText = "Photo N° " + nbPhoto.ToString(); // Nom de la photo monLabel = new Label(); monLabel.Text = "<div align=left>Nom de la photo : "; maTextBox = new TextBox(); maTextBox.ID = "T_PH" + nbPhoto.ToString() + "_name"; monValidateur = new RequiredFieldValidator(); monValidateur.ErrorMessage = " Le nom de la photo est oglibatoire !"; monValidateur.ControlToValidate = maTextBox.ID; monPanel.Controls.Add(monLabel); monPanel.Controls.Add(maTextBox); monPanel.Controls.Add(monValidateur); //Date de la photo monLabel = new Label(); monLabel.Text = "<br>Date de la photo : "; maTextBox = new TextBox(); maTextBox.ID = "T_PH" + nbPhoto.ToString() + "_version"; monPanel.Controls.Add(monLabel); monPanel.Controls.Add(maTextBox); // Commentaires monLabel = new Label(); monLabel.Text = "<br><br>Commentaires : <br>"; maTextBox = new TextBox(); maTextBox.ID = "T_PH" + nbPhoto.ToString() + "_comment"; maTextBox.TextMode = TextBoxMode.MultiLine; maTextBox.Height = Unit.Pixel(35); maTextBox.Width = Unit.Percentage(100); monPanel.Controls.Add(monLabel); monPanel.Controls.Add(maTextBox); // Distributeur monLabel = new Label(); monLabel.Text = "<br><br>Distributeur : <br><br>"; monPanel.Controls.Add(monLabel); // Organisation SQL monSQL = new SQL(); ArrayList org = monSQL.getAllORG(); monLabel = new Label(); monLabel.Text = "Organisation : "; monPanel.Controls.Add(monLabel); maDrop = new DropDownList(); maDrop.ID = "D_PH" + nbPhoto.ToString() + "_org"; maDrop.Items.Add(""); for (int j = 0; j < org.Count; j++) maDrop.Items.Add(org[j].ToString()); monPanel.Controls.Add(maDrop); monValidateur = new RequiredFieldValidator(); monValidateur.ErrorMessage = " Le nom de l'organisation est oglibatoire !"; monValidateur.ControlToValidate = maDrop.ID; monPanel.Controls.Add(monValidateur); monLabel = new Label(); monPanel.Controls.Add(monLabel); // Role monLabel = new Label(); monLabel.Text = "<br>Role : "; monPanel.Controls.Add(monLabel); maDrop = new DropDownList(); maDrop.ID = "D_PH" + nbPhoto.ToString() + "_role"; maDrop.Items.Add(""); maDrop.Items.Add("NOATTRIBUTION"); maDrop.Items.Add("resourceProvider"); maDrop.Items.Add("custodian"); maDrop.Items.Add("owner"); maDrop.Items.Add("user"); maDrop.Items.Add("distributor"); maDrop.Items.Add("originator"); maDrop.Items.Add("pointOfContact"); maDrop.Items.Add("principalInvestigator"); maDrop.Items.Add("processor"); maDrop.Items.Add("publisher"); maDrop.Items.Add("author"); monPanel.Controls.Add(maDrop); monValidateur = new RequiredFieldValidator(); monValidateur.ErrorMessage = " Le nom de l'organisation est oglibatoire !"; monValidateur.ControlToValidate = maDrop.ID; monPanel.Controls.Add(monValidateur); // Contact ArrayList ct = monSQL.getAllCT(); monLabel = new Label(); monLabel.Text = "<br><br>Contact : "; monPanel.Controls.Add(monLabel); maDrop = new DropDownList(); maDrop.ID = "D_PH" + nbPhoto.ToString() + "_contact"; for (int j = 0; j < ct.Count; j++) maDrop.Items.Add(ct[j].ToString()); monPanel.Controls.Add(maDrop); monLabel = new Label(); monPanel.Controls.Add(monLabel); // Transfert Option monLabel = new Label(); monLabel.Text = "<br><br>Option de transfert : <br>"; maTextBox = new TextBox(); maTextBox.ID = "T_PH" + nbPhoto.ToString() + "_transfertOption"; maTextBox.TextMode = TextBoxMode.MultiLine; maTextBox.Height = Unit.Pixel(35); maTextBox.Width = Unit.Percentage(100); monPanel.Controls.Add(monLabel); monPanel.Controls.Add(maTextBox); // style HTML monLabel = new Label(); monLabel.Text = "<div>"; monPanel.Controls.Add(monLabel); P_Distri.Controls.Add(monPanel); // Mon PlaceHolder } } }
Ce que je ne comprend pas, c'est que ma page me dit que là il n'y a aucun controle dans le PlaceHolder, alors que le premier bouton affiche bien les panels dans la PlaceHolder
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 protected void btnValidDistributon_Click(object sender, EventArgs e) { Page.Title = P_Distri.Controls.Count.ToString(); }
Le but de cela est de créer X champs de fomulaire afin de pouvoir remplir X panel avec des informations similaires.
Je suis prêt à changer l'organisation de mon code et de mon application si vous savez comment faire autrement.
Je vous remercie tous par avance !
PS : Si je ne suis pas assez clair, dites le moi et j'essayerais de mieux expliquer.
Partager