How to change decimal to% using .net

I have an Amount variable in my class ...

the value of this amount begins with the database as decimal. 0,000654345

when displayed in a grid, I need to show this as%. can anyboydy help me ..

thank

+5
source share
6 answers

Multiply by 100 and parse the result as a string and format it accordingly.

String parsedNum = String.Format("{0}%", num * 100);
+3
source

Use the "P" format , which we hope is more aware of globalization:

String.Format("{0:P4}", pos); // e.g. 1,000.0000%

Gridview, . 100x calc , , :). :

<asp:BoundField DataField="Db" DataFormatString="{0:P4}" />
+10

, , .

, 100... 10 000 "".

0.000654345?

+3
 Double yourValue = 0.00065;
 String percentage = (yourValue*100).ToString() + "%";
0

, Gridview, :

<ItemTemplate>
   <asp:Label id="Label1" runat="server"
         Text='<%# Eval("Amount", "{0:0%}") %>' />
</ItemTemplate>
0

100.

Console.WriteLine("Display percentage: {0:#.##%}", num);

# .

0

All Articles