c# - How to show multiple fields in combo box when using linq to sql? -
i have database of rice types , prices. has 3 fields: fld_ricetype
, fld_riceid
, fld_riceprice
. want show database in combobox. used code below:
cmbrice.displaymember = "fld_ricetype"; cmbrice.valuemember = "fld_riceid"; cmbrice.datasource = rnlq.tbl_rices.orderby(c => c.fld_ricetype).select(c => c);
i want change cmb.displaymember
show fld_ricetype + fld_riceprice
.
how can this?
fld_ricetype
nvarchar(50)
fld_riceprice
varchar(50)
i not sure if work try
orderby(c => c.ricetype).select(c => new { riceid = c.riceid, ricetype = c.ricetype, riceprice = c.riceprice, displayvalue = c.ricetype + ": " + c.riceprice })
and ofcourse use displayvalue displaymember
Comments
Post a Comment