I have a small LINQ query to populate a dropdown control (WinForms Telerik app ) with rows of data showing 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 };
//Now we can bind the results to the control
cbo.DataSource = query.ToList();
cbo.DisplayMember = "cboText";
cbo.ValueMember = "ID";
Which works fine. But I want the user to be able to switch the order of the "cboText" - as in sometimes it shows as ITNBR - Description and sometimes it shows as Description - ITNBR
Is there any way to do this without writing two separate LINQ queries? thanks in advance.
Aucun commentaire:
Enregistrer un commentaire