Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6702847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:06:05+00:00 2026-05-26T07:06:05+00:00

I have a model property I’m trying to render using an EditorFor template, and

  • 0

I have a model property I’m trying to render using an EditorFor template, and I’m trying to apply formatting using the DisplayFormat attribute. However, it’s not working at all — it’s totally being ignored.

Here is my template:

@model System.Decimal?
@Html.TextBoxFor(m => m)

Here is my model:

[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:0.00}")]
public decimal? Retail { get; set; }

Here is my view:

@Html.EditorFor(m => m.Retail)

But it’s rendering a textbox with the following value:

189.9900

It seems pretty straight forward, but it’s not working, and I have no idea why.

UPDATE:
Just for kicks, I tried it with a DisplayFor template, and it worked:

@Html.DisplayFor(m => m.Retail)

So why would the DisplayFor template work, but not the EditorFor template, when I’ve set ApplyFormatInEditMode to true?

UPDATE 2:
Never mind, the reason that worked is because my Decimal display template was hard-coded to format that way. So my display template also does not work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:06:06+00:00Added an answer on May 26, 2026 at 7:06 am

    Darin Dimitrov posted this answer, and I was able to get it working using his solution:

    @Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue)
    

    A bit crude, IMO, that this doesn’t work w/ TextBoxFor, but at least it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom attribute 'RoleAction' and added to the model property public
I have a Model Property which has subclasses using STI, and which I would
I'm writing an application using WPF MVVM. I have a view model with property
How do I bind a view model property to the ListBox.SelectedItem property? I have
I have a view model with a property Fields which is an ObservableCollection<FieldVM> .
I have the following classes in my ActiveRecord model: def Property < ActiveRecord::Base #
How can I override the IsValid property? I have a model that's validating as
I have an MVC application. The model has a property that is a struct
I have a date time property in a linq to sql model and I
Similar to this post IEnumerable model property in an ASP.NET MVC 3 Editor Template

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.