DisplayFormat for TextBoxFor in MVC

后端 未结 5 493
孤独总比滥情好
孤独总比滥情好 2020-12-09 02:56

I need to round off 4 digit decimal to 2 digits and show in MVC 3 UI

Something like this 58.8964 to 58.90

Tried following this How should I

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 03:34

    Try like this:

    @{
         var format = String.Format("{0:0.00}", Model.TotalAmount);
    }
    @Html.TextBoxFor(m => m.TotalAmount, format)
    

    Hope it helps.

提交回复
热议问题