0

Currently, i display data of currency without format, witch is visibly bad. I look for a way to format this data before show him. I use asp.net mvc and Razor.

<table class="table table-striped" >
            <tr>
                <th style="min-width:130px;">Month</th>
                <th style="min-width:80px;">Value 1</th>
                <th style="min-width:100px;">Value 2</th>
                <th style="min-width:100px;">Value 3</th>
            </tr>
            @foreach (TB_DADOS dados in dm){
                <tr>
                    <td>@dados.DT_MONTH.ToString(CultureInfo.CreateSpecificCulture("pt-BR"))</td>
                    <td><span class="money" /> @dados.Value1</td>
                    <td><span class="money" /> @dados.Value2</td>
                    <td><span class="money" /> @dados.Value3</td>
                </tr>
            }
        </table>

(see the image below)

How data is shown currently

How can i format this before show?

Thanks!

Csorgo
  • 171
  • 2
  • 13

1 Answers1

0

Use DateTime.ToShortDateString(): https://msdn.microsoft.com/pt-br/library/system.datetime.toshortdatestring(v=vs.110).aspx

For currency, try this:

System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
customCulture.NumberFormat.NumberDecimalSeparator = ",";
System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

Reference: Set up dot instead of comma in numeric values