Link to home
Start Free TrialLog in
Avatar of awilderbeast
awilderbeastFlag for United Kingdom of Great Britain and Northern Ireland

asked on

c# winform get all rows from one column into dictionary and bind to list?

hi all my code below should hopefully explain where im trying to get to if someone could point out the errors and put me in the right direction?

i want all the rows from the column Trades in the Trades Table and get them in a dictionary and bind them

Thanks
Dictionary<string, string> dictATrades = new Dictionary<string, string>();
            foreach (DataRow trade in dataSetMisc.Trades.Rows)
            {
                dictATrades.Add((string)(trade["Trades"]), (string)(trade["Trades"]));
            }
            var dictATradesSort = (from entry in dictATrades orderby entry.Value ascending select entry);

            lstAvailbleTrades.DataSource = new BindingSource(dictATradesSort, null);
            lstAvailbleTrades.DisplayMember = "Value";
            lstAvailbleTrades.ValueMember = "key";

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of RGBDart
RGBDart
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For one thing, you're putting the same value in both the key and value properties of each dictionary element.  Could that be why it's not working for you?
Avatar of awilderbeast

ASKER

thanks