1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

TextBoxFor Decimal Member without decimal places

Discussion in 'C#' started by DmitryS, Mar 3, 2011.

  1. #1
    Hi,

    I got a decimal member in my viewmodel and get populated from the database (say 55.5, or 100.00)

    In my view I use TextBoxFor<> for this member.

    Is there any way to have a number (it's actually a percentage) like 100.00 display as 100 instead, and 55.50 as 55.5?

    Probably a stupid question (really tired here)
     
    DmitryS, Mar 3, 2011 IP
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Wouldn't casting it to a double deal with the issue?
    double.Parse(YourDecimal).ToString()
    Code (markup):
     
    AstarothSolutions, Mar 5, 2011 IP
  3. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    CInt(num) ................
     
    camjohnson95, Mar 5, 2011 IP