ASP.NET: Gridview Formatting Columns with DataFormatString
-
28-02-2021 - |
Pergunta
I want to change these values with DataFormatString properties in Gridview
.
1.000000
--> 1
--> Deleting all digits after .
366705.000000
--> 366,705
--> Deleting all digits after .
and put the comma for seperate.
12.830000
--> %12,83
--> Delete last 4 digits after .
and put %
(% is optinal not must)
BTW, Is there any link to suggest me otherwise DataFormatString. I analyze very well this page but sometimes still can't find what I need about data format string.
Solução
Here you go. I didn't test #3 - if it's not right, it's close.
1
Convert the number
to an int
.
2
String.Format("{0:n"}, 366705);
3
(12.83 / 100).ToString("{%#0.00}", el-GR);
A couple helpful formatting web pages:
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow