How do I get DisplayFormat to work in my View using ASP.NET MVC 3?

I have the following in my model.

[DisplayFormat(DataFormatString = "{0.0}")]
public double Rating { get; set; }

I have the following in my view
@Html.DisplayFor(modelItem => item.Rating)

This is not working for me. I get an error on my page:

"Input string was not in a correct format."
maddhacker24Asked:
Who is Participating?
 
maddhacker24Author Commented:
I solved the issue myself.

I used [DisplayFormat(DataFormatString = "{0:0.0}", ApplyFormatInEditMode = true)]
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.