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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -