我有一个字段的数据类型是 decimal
得出来的数据小数点后面有很多零 如:1280.00000 
我想去掉这些多余的零怎么写<%#Eval("SoftPrice"> 数据是这样绑定显示的
大家帮我看看吧,到网上找了好久也没搞定!!

解决方案 »

  1.   

    在后台先把它转成字符串型不行吗不行的话在后台用SUBSTRING函数
      

  2.   

    NumberFormatInfo nfi=new NumberFormatInfo();  
    nfi.NumberDecimalDigits = 2;  
    result = Convert(number,nfi);   
      

  3.   

    用decimal.Round()方法,假如你有一个decimal变量   mydecimal,值为   99.9887,你可以用:  
       
    decimal.Round(mydecimal,2);  
       
    将它转换为99.99。
      

  4.   

    不是的,我必须要在 <%#Eval("SoftPrice")%>这里处理啊
      

  5.   

    <%#decimal.Round(Convert.ToDecimal(Eval("SoftPrice")),2)%>
      

  6.   

    再封装数据源的时候 就把这个值规范化。使用decimal的Round()方法就就可以
    decimal SoftPrice =1.125;
    SoftPrice =decimal.Round(SoftPrice, 2),
    最后SoftPrice的值是1.12