var term = from s in DB.Terms
select new { s.Term_ID, s.TermName };
comboboxTerm.DataSource = term;
combobox.DisplayMember = "Term_Name";
combobox.ValueMember = "Term_ID";
i want to convert the above query to a list<> such that i can set the list as the Datasource to comboboxTerm. That would enable me get access to comboboxTerm selectedValue in code.
Change it to:
This will actually resolve your query as well, as by default you’re returning an
IQueryableBUT for the Data Source of the combobox, you’re best off using a dictionary, like so:
Then add the following to your combobox: