Concatenating special character in razor (lambda exp) [Resolved]

Posted by Self-Innovator under ASP.NET MVC on 4/20/2016 | Points: 10 | Views : 3611 | Status : [Member] | Replies : 1
Hi ,

I wanted to add an special character : in my razor view which is currently binded via lambda expression

@Html.DisplayFor(x => x.StoreProfileAssociation.RegionalManager.Title)


I tried in this way but throws an exception

@Html.DisplayFor(string.Format("{0}{1}", x => x.StoreProfileAssociation.RegionalManager.Title,":")


Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

Posted by: Rajnilari2015 on: 4/20/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
@Html.DisplayFor needs a property to map to, so a concatenation is impossible. Alternate way is to expose a property in your view model and perform the concatenation there and then bind to your view engine.

--
Thanks & Regards,
RNA Team

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response