Bonsoir à tous, je me trouves fasse à un problème que je n'arrive pas à résoudre :
J'ai créé un datagridview, que j'ai lié à une list d'objet. Jusqu'à la tout va bien.
Le problème est que peut importe le nombre d'objet présent dans ma liste, je n'en vois qu'un seul dans le datagridview ...
Je ne vois pas d'où cela peut provenir.
Je vous laisse un petit bout de code si cela peut vous aider :
Merci 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 private List<LigneCommande> MaListe = new List<LigneCommande>(); dgvtest.DataSource = MaListe; SqlCommand CmdLigneFact = new SqlCommand("select * from contenir where Num_fact =" + Convert.ToInt32(cbbtest.SelectedItem.ToString()), Conn); SqlDataReader DbReaderLigneFact = CmdLigneFact.ExecuteReader(); bool maLigneEtat = DbReaderLigneFact.Read(); //string MaLignefacture = ""; while (maLigneEtat) { LigneCommande LC = new LigneCommande(); Produit P = new Produit(); SqlCommand ProduitNom = Conn.CreateCommand(); ProduitNom.CommandText = "Select NOM_P from Produit where NUM_P=" + Convert.ToInt32(DbReaderLigneFact[2]) + ";"; P.NomProduit = ProduitNom.ExecuteScalar().ToString(); P.NumProduit = Convert.ToInt32(DbReaderLigneFact[2]); LC.LeProduit = P; SqlCommand NomTypeCmd = Conn.CreateCommand(); NomTypeCmd.CommandText = "Select NOM_TYPE from TYPE_CONDITIONNEMENT where NUM_TYPE =" + Convert.ToInt32(DbReaderLigneFact[0]) + ";"; LC.Conditionemment = NomTypeCmd.ExecuteScalar().ToString(); LC.Qte_Produit = Convert.ToInt32(DbReaderLigneFact[3]); MaListe.Add(LC); maLigneEtat = DbReaderLigneFact.Read(); }
Partager