Bien le bonjour !
Je me retrouve devant un gros questionnement.. Je cherche à faire un tableau dynamique avec des checkbox. Malheureusement pour moi, lorsque je fais mon cb.Attributes.Add(maCondition, maProcedure) il fait pas ce que je veux...
ça, c'est ma procédure, et lorsqu'il exécute ma page
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 void setTbChiffres() { Conn.monSQLData("avancementSaisieChiffres"); //Affectation de la Procedure Stockée à la connexion Conn.myReader = Conn.myComm.ExecuteReader(); //Execution de la commande et stockage des données dans un Reader Conn.myReader.Read(); do { TableRow tr = new TableRow(); TableCell tc2 = new TableCell(); switch ((int)Conn.myReader.GetValue(1)) { case 0: tc2.BackColor = System.Drawing.Color.Orange; break; case 1: tc2.BackColor = System.Drawing.Color.LightGreen; break; default: tc2.BackColor = System.Drawing.Color.Red; break; } CheckBox cb = new CheckBox(); cb.AutoPostBack = true; cb.Text = (string)Conn.myReader.GetValue(0); cb.ID = "cb" + Convert.ToString((int)Conn.myReader.GetValue(2)); cb.Attributes.Add("OnCheckedChanged", "CheckedChanged"); //Affectation de l'attribut "OnCheckedChanged" à ma CheckBox if ((int)Conn.myReader.GetValue(1) == 1) cb.Checked = true; else cb.Checked = false; tc2.HorizontalAlign = HorizontalAlign.Left; tc2.Controls.Add(cb); tr.Controls.Add(tc2); tbChiffres.Controls.Add(tr); } while (Conn.myReader.Read()); }
j'ai pas vraiment besoin de tout ça.. j'aimerais bien, qu'il execute la fonction que je lui passe en attribut... hors, il met le "CheckedChange" avant sur un span avant ma ChkBox... je vois pas ou est mon erreur dans mon code, si quelqu'un pouvait m'aider je lui en serait très reconnaissant.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 <td align="left" style="background-color:LightGreen;"><span OnCheckedChanged="CheckedChanged"><input id="ctl00_contenuegeneral_cb2" type="checkbox" name="ctl00$contenuegeneral$cb2" checked="checked" onclick="javascript:setTimeout('__doPostBack(\'ctl00$contenuegeneral$cb2\',\'\')', 0)" /><label for="ctl00_contenuegeneral_cb2">monTexte</label></span></td>
Cordialement,
Lyche
Partager