awilderbeast
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
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";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
ASKER
thanks