-2

我想通过使用带有属性的 DisplayFormat 属性在侧面文本框中显示百分比 (%) 符号。

我正在使用 MVC3

我的模型是

public class CommodityParticularInfo : EntityBase
{
    private decimal? _standardReceived;
    public decimal? StandardReceived
    {
        get { return _standardReceived; }
        set { _standardReceived = value; }
    }
}

视图是

@Html.TextBoxFor(m => m.StandardReceived, new { @class = "textboxreadonly", @style = "width:100%", @ReadOnly = "ReadOnly" })
4

2 回答 2

0

尝试使用 0'%' 作为 DisplayFormatString,(单引号中的百分比)这应该有助于实现将百分比符号附加到您的数字。所以你得到33%。

您可以尝试的另一件事可能是 0\% (不确定它是否有效),但应该可以达到您想要的 33%。

显示格式字符串,int 到百分比

于 2013-04-04T21:34:00.523 回答
0

尝试:

 [DisplayFormat(DataFormatString = "{0:P2}")]     
 public decimal? StandardReceived
 {
       get { return _standardReceived; }
       set { _standardReceived = value; }
 }
于 2013-04-04T21:34:38.020 回答