![](/img/trans.png)
[英]How to display decimal value to 2 decimal places in datatable to display in datagrid
[英]2 decimal places in web grid for mvc - need total value to display value with 2 decimal places
Web網格中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")
})
不知道您的SelfBillItemTotalvalue
屬性的類型,我只能建議這樣做:
grid.Column(
columnName: "SelfBillItemTotalvalue",
header: "Total Value",
format: item => item.ToString("#.##")
)
試試這個你也可以添加這樣的列
columns: grid.Columns(
grid.Column(header: "SelfBillItemTotalvalue", format: @<text>String.Format("{0:0.##}", @item.SelfBillItemTotalvalue) </text>, style: "remo")
)
您應該更改此行:
grid.Column(columnName: "SelfBillItemTotalvalue", header: "Total Value")
在這個:
grid.Column(header: "Total Value", format: item => String.Format("{0:0.00}", item.SelfBillItemTotalvalue))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.