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

  • Home
  • SEARCH
  • 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 7403871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:10:20+00:00 2026-05-29T05:10:20+00:00

My application is in asp.Net MVC3 coded in C#.Net. I want to truncate the

  • 0

My application is in asp.Net MVC3 coded in C#.Net.

I want to truncate the decimal part of my values when they are displayed in the TextBoxes.
The DataType for these values are set to Decimal in the database so even if i save 150 it saves as 150.0000.And when it displays a particular record it comes back as 150.0000 but i dont want it that way,i only want 150.

I have tried

  @Html.TextBoxFor(string.Format("Decimal Truncation Format", model => model.myValue))

But not working..The values are travelling from many views.
So can i have such a truncation in the model itself so that it applied to that value all the time.

If not possible that way then how can i achieve it.?

  • 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-29T05:10:21+00:00Added an answer on May 29, 2026 at 5:10 am

    Why don’t you modify the property in your ViewModel to Int32? That should solve your problem in an instant!

    EDIT:

    This assumes that you have a ViewModel. You should never bind views directly to your db, but to a view-specific model (the ViewModel). Then you can modify that ViewModel as much as you want, so that it serves the needs of the View rather than those of the DB.

    Check out the following links:

    • http://stephenwalther.com/blog/archive/2009/04/13/asp.net-mvc-tip-50-ndash-create-view-models.aspx
    • http://rachelappel.com/use-viewmodels-to-manage-data-amp-organize-code-in-asp.net-mvc-applications
    • http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx
    • http://weblogs.asp.net/shijuvarghese/archive/2010/02/01/view-model-pattern-and-automapper-in-asp-net-mvc-applications.aspx

    Good luck!

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

Sidebar

Related Questions

My application is in Asp.Net MVC3 coded in C#.Net. I have Views which contains
My Application is in Asp.Net MVC3 coded in C#. This is what my requirement
I'm using Entity Framework(4.3) Code First Method For My Asp.Net Mvc3 Application.I want to
I am implementing a web application using ASP.NET MVC3. In the application I want
My application is in Asp.net MVC3 coded in C#.Net. I have a view which
My application is in Asp.Net MVC3 coded in C#.Net. Im using google Currency Conversion
I am working on a web application (asp.net mvc3) I have a Main div.
I am going to build my application using asp.net mvc3 and nhibernate 3.2. I
My application is in ASP.net MVC3. I have a table of elements. An element
In my asp.net mvc3 application, I have a custom Authorization Attribute as seen below.

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.