Skip to main content
edited tags
Link
tereško
  • 58.3k
  • 25
  • 99
  • 150
Source Link
Nate Pet
  • 45.6k
  • 127
  • 272
  • 418

MVC Razor need to get Substring

I have the following inside of my view

     @Html.DisplayFor(modelItem => item.FirstName)

I need to get the first initial of the First Name.

I tried

    @Html.DisplayFor(modelItem => item.FirstName).Substring(1,1) 

but it does not seem to work. I get the following error: .. 'System.Web.Mvc.MvcHtmlString' does not contain a definition for 'Substring' and no extension