Bonjour,
je suis dans le développement d'une application web pour une demande d'intervention. Dans ce context j'ai réalisé un tableau comme cela :
avec un imageButton et une textBox dans chaque ligne, tout s'affiche et j'arrive bien dans la méthode appelé lors du click qui est : monBouton_click
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 TableRow ligne = new TableRow(); //date TableCell cel1 = new TableCell(); cel1.Text = dr.GetString(2); cel1.BorderWidth = 1; ligne.Cells.Add(cel1); //service TableCell cel2 = new TableCell(); cel2.Text = dr.GetString(3); cel2.BorderWidth = 1; ligne.Cells.Add(cel2); //nom TableCell cel3 = new TableCell(); cel3.Text = dr.GetString(4); cel3.BorderWidth = 1; ligne.Cells.Add(cel3); //type TableCell cel4 = new TableCell(); cel4.Text = dr.GetString(6); cel4.BorderWidth = 1; ligne.Cells.Add(cel4); //etat TableCell cel5 = new TableCell(); cel5.Text = " <a href='traitement.aspx?x=" + dr["etat"] + "&y=" + dr["code_intervention"] + "' style='text-decoration:none; color:black; border:0px;'> <img src='images/Forward.png'style='border:0px;'></a>"; cel5.BorderWidth = 1; ligne.Cells.Add(cel5); //suivie TableCell cel6 = new TableCell(); maTextBox = new TextBox(); maTextBox.ID = "tb"+dr[0].ToString(); monBouton = new ImageButton(); monBouton.ImageUrl = "images/next.png"; monBouton.ID = dr[0].ToString(); monBouton.Click += new ImageClickEventHandler(monBouton_click); cel6.Controls.Add(maTextBox); cel6.Controls.Add(monBouton); cel6.BorderWidth = 1; ligne.Cells.Add(cel6); string etat = dr["etat"].ToString(); if (etat == "0") { ligne.BackColor = System.Drawing.Color.Tomato; } else if (etat == "1") { ligne.BackColor = System.Drawing.Color.Orange; } else if (etat == "2") { ligne.BackColor = System.Drawing.Color.LightGreen; } Table1.Rows.Add(ligne);
dans cette méthode je veux parcourir tous les controles de ma page pour trouver la textBox qui à l'ID : "tb"+dr[0].ToString();
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 protected void monBouton_click(object sender, ImageClickEventArgs e) { foreach (Control c in this.Form.Controls) { if (c.GetType() == typeof(TextBox)) //vérifier le casting { TextBox tb = (TextBox)c; //casting effectif Label2.Text += tb.Text; //ici je rentre dans mon label2 tout le contenue de toute mes textBox juste pour tester } } }
mais pour le momant je n'arrive pas à trouver mes textBox en parcourant ma page.
si quelqu'un à une idée ....
merci bcp
Partager