mvc的网格中有2个小数位 - 需要总值才能显示带小数点后2位的值
@grid.GetHtml(
tableStyle: "table",
fillEmptyRows: true,
headerStyle: "header",
footerStyle: "grid-footer",
mode: WebGridPagerModes.All,
columns: new[]
{
grid.Column(columnName: "SelfBillInvoiceNumber", header: "Invoice Number"), //the model fields to display
grid.Column(columnName: "SelfBillItemTotalvalue", header: "Total Value")
})
答案 0 :(得分:0)
在不知道SelfBillItemTotalvalue
属性的类型的情况下,我只能推荐这个:
grid.Column(
columnName: "SelfBillItemTotalvalue",
header: "Total Value",
format: item => item.ToString("#.##")
)
答案 1 :(得分:0)
试试这个你可以添加这样的列
columns: grid.Columns(
grid.Column(header: "SelfBillItemTotalvalue", format: @<text>String.Format("{0:0.##}", @item.SelfBillItemTotalvalue) </text>, style: "remo")
)
答案 2 :(得分:0)
您应该更改此行:
grid.Column(columnName: "SelfBillItemTotalvalue", header: "Total Value")
在这一个中:
grid.Column(header: "Total Value", format: item => String.Format("{0:0.00}", item.SelfBillItemTotalvalue))