Link to home
Create AccountLog in
Avatar of eli411
eli411

asked on

Removing Leading Zero in the MVC project

I have my code in the MVC project in the following.

Razor form code below ---------------------------------------------------------------------------------------------------------

@Html.DisplayFor(model => model.fico222)        Which displays fico score (String) Ex: 0790
-------------------------------------------------------------------------------------------------------------------------------------------


Model class code below---------------------------------------------------------------------------------------------------------
        [DisplayName("Credit Score")]
        public string fico222 { get; set; }

----------- I wanted the returning fico score return with 790 instead of 0790 so how can I change that in my syntax??  
Thank you!
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Try this line of code for yours.
@Html.DisplayFor(model => model.fico222.TrimStart('0'))

Open in new window

Avatar of eli411
eli411

ASKER

Got following errors

Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.
Avatar of eli411

ASKER

Here is the error from the Visual Studio

{"Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions."}
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of eli411

ASKER

thank you Fernado!
Hi eli411;

If my last post answered your question please mark it as the solution to the question.

Thank you.
Avatar of eli411

ASKER

The syntax works!  Thanks Fernando.
its doesn't work for me