ASP.NET中datagrid 如何设置小数位数?

来源:百度知道 编辑:UC知道 时间:2024/05/10 13:32:22

1、可以在 <asp:HyperLinkColumn> 的 DataTextFormatString 设置 如:
DataTextFormatString = "{0:F}"
DataTextFormatString = "{0:F0}"
DataTextFormatString = "{0:F2}"
例如 123.456 → {0:F2} → 123.46

2、在 <asp:BoundColumn> 则是 DataFormatString 中设置,设置内容同上

使用F,N都可以的,即{0:F2} {0:N2}

有:
1234.567 → {0:F2} → 1234.57
1234.567 → {0:N2} → 1,234.57

就这样,ok了