I have a small LINQ query to populate a drop-down control (WinForms Telerik application) with data rows displaying two values (ITNBR and description):
var query = from i in db.ItemMasts.AsNoTracking()
orderby i.ITNBR
select new { i.ID, cboText = i.ITNBR + " - " + i.Description };
cbo.DataSource = query.ToList();
cbo.DisplayMember = "cboText";
cbo.ValueMember = "ID";
Which works great. But I want the user to be able to switch the order of "cboText" - as sometimes it is displayed as ITNBR - Description, and sometimes it is displayed as "Description" - ITNBR
Is there a way to do this without writing two separate LINQ queries? thanks in advance.
source
share