开发者

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 })
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜