How to format Webgrid Currency column?

Asked

Viewed 143 times

0

How to format the column Valor of Webgrid ? Example of 3000,000 for 3,000.00 ?

    @grid.GetHtml(
    tableStyle: "webgrid",
    headerStyle: "header",
    alternatingRowStyle: "alt",
    selectedRowStyle: "select",
    footerStyle: "footer",
    columns: grid.Columns(
    grid.Column("", format: @<text><div style="float:left; width:100%"><div style="float:left; width:75%"><strong>Fornecedor:</strong>&nbsp;&nbsp;@item.NomeFantasia</div><div style="float:left; width:25%">&nbsp;&nbsp;<strong>Data Venc.:</strong>&nbsp;&nbsp;@item.DtVencimento.ToString("dd/MM/yyyy") </div></div><br /><div style="float:left; width:75%">&nbsp;&nbsp;<strong>Valor Doc.:</strong>&nbsp;&nbsp;@item.ValorDocumento</div><div style="float:left; width:25%">&nbsp;&nbsp;<strong>Situação:</strong>&nbsp;&nbsp;@item.NmTipoSituacao</div><br /><div style="float:left; width:100%">&nbsp;&nbsp;<strong>Descrição:</strong>&nbsp;&nbsp;@item.DsMovimento</div></text>)

    )
)

1 answer

1


One option would be to replace this code:

<strong>Valor Doc.:</strong>&nbsp;&nbsp;@item.ValorDocumento

By that code:

<strong>Valor Doc.:</strong>&nbsp;&nbsp;@string.Format(new System.Globalization.CultureInfo("pt-BR"), "{0:c}", @item.ValorDocumento)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.