Bonjour,
SVP je veux quand je selectionne une valeur de mon dropdownlist1 recuperer les données qui correspondent à ma selection depuis la BDD dans un autre dropdownlist2.
le problème c'est que les données qui s'affichent dans mon ddl2 sont par défaut celles de la première valeur dans mon ddl1.
voila ce que j'ai fait:
merci pour votre aide.
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 protected void Page_Load(object sender, EventArgs e) { String str = "Data Source=PC-01;Initial Catalog=GEL; Integrated Security=True;Asynchronous Processing = true"; SqlConnection conn = new SqlConnection(str); conn.Open(); SqlCommand comm = new SqlCommand("select distinct num_dossier_an from gel", conn); SqlDataReader sdr = comm.ExecuteReader(); if (sdr.HasRows) { DropDownList1.DataSource = sdr; DropDownList1.DataTextField = "num_dossier_an"; DropDownList1.DataBind(); } sdr.Close(); SqlCommand com = new SqlCommand("select num_dossier_num from gel where num_dossier_an='" + DropDownList1.SelectedValue + "'", conn); SqlDataReader sdrn = com.ExecuteReader(); if (sdrn.HasRows) { DropDownList3.DataSource = sdrn; DropDownList3.DataTextField = "num_dossier_num"; DropDownList3.DataBind(); } } }
Partager