Bonjour à tous, j'ai un petit problème avec cet évènement, je m'explique :
je fais un formulaire dans le quelle est situé une listbox, j'aimerai que lorsque l'utilisateur sélectionne un objet dans cette listbox un tableau soit crée dynamiquement et cela sans avoir à appuyer sur un bouton de type submit.
Me problème que je rencontre et que lorsque je clique dans ma listebox et que l'index change, rien ne se passe, pourtant la méthode est bien abonnée ( enfin je pense ^^)
je vous met le code ici :
et la méthode :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <form runat="server" id="frmtable"> <p align="center"> Choisissez un état dans la liste <asp:ListBox ID="list_tri" rows="1" OnSelectedIndexChanged="tableau_prob_load" runat="server" /> <br /> </p> </form>
Je vous remercie d'avance.
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 public void tableau_prob_load(object o, EventArgs e) { OdbcConnection connection = new OdbcConnection(); connection.ConnectionString = ConfigurationManager.ConnectionStrings["maConnexion"].ToString(); try { connection.Open(); OdbcCommand DbcommandEtatId = connection.CreateCommand(); DbcommandEtatId.CommandText = "Select Etat_id from etat_probleme where Etat_libelle='" + list_tri.SelectedItem.Text +"'"; OdbcDataReader DbReaderEtatId = DbcommandEtatId.ExecuteReader(); DbReaderEtatId.Read(); //Requête pour récuperer le libellé des catégories OdbcCommand DbCommand = connection.CreateCommand(); DbCommand.CommandText = "select * from probleme where Etat_ID='"+DbReaderEtatId.GetInt32(0) +"' order by Etat_ID, Prob_ID;"; OdbcDataReader DbReader = DbCommand.ExecuteReader(); while (DbReader.Read()) { OdbcCommand DbCommandListboxEtat = connection.CreateCommand(); DbCommandListboxEtat.CommandText = "select Etat_libelle from etat_probleme"; OdbcDataReader DbreaderListBoxEtat = DbCommandListboxEtat.ExecuteReader(); HtmlSelect Liste_etat = new HtmlSelect(); Liste_etat.Items.Clear(); while (DbreaderListBoxEtat.Read()) { Liste_etat.Items.Add(DbreaderListBoxEtat.GetString(0)); } HtmlTableRow ma_ligne_prob = new HtmlTableRow(); HtmlTableCell ma_cellule_num_prob = new HtmlTableCell(); HtmlTableCell ma_cellule_titre_prob = new HtmlTableCell(); HtmlTableCell ma_cellule_cat_prob = new HtmlTableCell(); HtmlTableCell ma_cellule_os_prob = new HtmlTableCell(); HtmlTableCell ma_cellule_mod_prob = new HtmlTableCell(); HtmlTableCell ma_cellule_msg_prob = new HtmlTableCell(); HtmlTableCell ma_cellule_etat_prob = new HtmlTableCell(); HtmlTableCell ma_cellule_modif_etat = new HtmlTableCell(); HyperLink link_titre = new HyperLink(); link_titre.Text = DbReader.GetString(1); link_titre.NavigateUrl = "forumA_show_topic.aspx?ref_prob=" + DbReader.GetInt32(0); ma_cellule_titre_prob.Controls.Add(link_titre); ma_cellule_num_prob.InnerText = DbReader.GetInt32(0).ToString(); OdbcCommand DbCommandCat = connection.CreateCommand(); DbCommandCat.CommandText = "select lib_liste_lib from libelle_liste where Categorie_Num='2' and Lib_Liste_num=" + DbReader.GetInt32(6); OdbcDataReader DbReaderCat = DbCommandCat.ExecuteReader(); DbReaderCat.Read(); ma_cellule_cat_prob.InnerText = DbReaderCat.GetString(0); OdbcCommand DbCommandOs = connection.CreateCommand(); DbCommandOs.CommandText = "select lib_liste_lib from libelle_liste where Categorie_Num='1' and Lib_Liste_num=" + DbReader.GetInt32(7); OdbcDataReader DbReaderOs = DbCommandOs.ExecuteReader(); DbReaderOs.Read(); ma_cellule_os_prob.InnerText = DbReaderOs.GetString(0); OdbcCommand DbCommandMod = connection.CreateCommand(); DbCommandMod.CommandText = "select lib_liste_lib from libelle_liste where Categorie_Num='3' and Lib_Liste_num=" + DbReader.GetInt32(8); OdbcDataReader DbReaderMod = DbCommandMod.ExecuteReader(); DbReaderMod.Read(); ma_cellule_mod_prob.InnerText = DbReaderMod.GetString(0); ma_cellule_msg_prob.InnerText = DbReader.GetString(3); OdbcCommand DbCommandEtat = connection.CreateCommand(); DbCommandEtat.CommandText = "Select etat_libelle from etat_probleme where Etat_id=" + DbReader.GetInt32(15); OdbcDataReader DbReaderEtat = DbCommandEtat.ExecuteReader(); DbReaderEtat.Read(); ma_cellule_etat_prob.InnerText = DbReaderEtat.GetString(0); ma_cellule_modif_etat.Controls.Add(Liste_etat); ma_cellule_num_prob.Width = "7%"; ma_cellule_titre_prob.Width = "13%"; ma_cellule_cat_prob.Width = "7%"; ma_cellule_os_prob.Width = "9%"; ma_cellule_mod_prob.Width = "7%"; ma_cellule_msg_prob.Width = "40%"; ma_cellule_etat_prob.Width = "7%"; ma_cellule_modif_etat.Width = "10%"; ma_cellule_num_prob.BgColor = "#EFEFDD"; ma_cellule_titre_prob.BgColor = "#EFEFDD"; ma_cellule_cat_prob.BgColor = "#EFEFDD"; ma_cellule_os_prob.BgColor = "#EFEFDD"; ma_cellule_mod_prob.BgColor = "#EFEFDD"; ma_cellule_msg_prob.BgColor = "#EFEFDD"; ma_cellule_etat_prob.BgColor = "#EFEFDD"; ma_cellule_modif_etat.BgColor = "#EFEFDD"; ma_cellule_num_prob.Align = "center"; ma_cellule_titre_prob.Align = "center"; ma_cellule_cat_prob.Align = "center"; ma_cellule_os_prob.Align = "center"; ma_cellule_mod_prob.Align = "center"; ma_cellule_msg_prob.Align = "center"; ma_cellule_etat_prob.Align = "center"; ma_cellule_modif_etat.Align = "center"; ma_ligne_prob.Cells.Add(ma_cellule_num_prob); ma_ligne_prob.Cells.Add(ma_cellule_titre_prob); ma_ligne_prob.Cells.Add(ma_cellule_cat_prob); ma_ligne_prob.Cells.Add(ma_cellule_os_prob); ma_ligne_prob.Cells.Add(ma_cellule_mod_prob); ma_ligne_prob.Cells.Add(ma_cellule_msg_prob); ma_ligne_prob.Cells.Add(ma_cellule_etat_prob); ma_ligne_prob.Cells.Add(ma_cellule_modif_etat); Prob_table.Rows.Add(ma_ligne_prob); } connection.Close(); } catch (Exception ex) { lblerror.Text = ex.Message; } }
Partager