Grab data from table, join string from two columns, display in MVC selectList
I am new to MVC and LINQ.
I have a table with three columns (id, text1, text2). What I want to do is generate a selectList in my view which has DataValue set to table.id, and DataText set to be = text1 + ", " + text2; (i.e. join开发者_如何学运维 text1 and text2 with comma separation).
What do you reckon is the best way to achieve this?
Cheers,
Tim.
Something like this perhaps?
var v = dc.threecolumntable.Select(x => new {DataValue = x.id, DataText = x.text1 + ", " + x.text2 })
精彩评论