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
Multiply by 100 and parse the result as a string and format it accordingly.
String parsedNum = String.Format("{0}%", num * 100);
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}" />
, , .
, 100... 10 000 "".
0.000654345?
Double yourValue = 0.00065; String percentage = (yourValue*100).ToString() + "%";
, Gridview, :
<ItemTemplate> <asp:Label id="Label1" runat="server" Text='<%# Eval("Amount", "{0:0%}") %>' /> </ItemTemplate>
100.
Console.WriteLine("Display percentage: {0:#.##%}", num);
# .