Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1941
  • Last Modified:

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."
0
maddhacker24
Asked:
maddhacker24
1 Solution
 
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.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now