Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How i can bind DataGridview with Hashtable

I am do it but i store object in hashtable so when i bind the object appears but i want what inside object ( all property )

C#
ht.Add("p", new Products { P_Name = "productA", P_Price = 20 });
         ht.Add("p2", new Products { P_Name = "productB", P_Price = 20 });
         dataGridView1.DataSource = ht.Cast<DictionaryEntry>()
                          .Select(x => new
                          {
                             // col = (from s in x.Value select new Products { P_Name, P_Price }),
                              Colum = x.Key.ToString(),
                              Colum1 = x.Value.ToString()
                          })
                          .ToList();
Posted

Maybe...
C#
ht.Add("p", new Products { P_Name = "productA", P_Price = 20 });
         ht.Add("p2", new Products { P_Name = "productB", P_Price = 20 });
         dataGridView1.DataSource = ht.Cast<dictionaryentry>()
                          .Select(x => new
                          {
                             // col = (from s in x.Value select new Products { P_Name, P_Price }),
                              Colum = x.Key.ToString(),
                              Colum1 = x.Value.P_Name.ToString(),
                              Column2 = x.Value.P_Price.ToString()
                          })
                          .ToList();
 
Share this answer
 
v2
Comments
elangovan4ever 15-Sep-18 0:29am    
Could you please post VB.net version of this code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900