I want to remove all the decimal points from a decimal value and add a ‘%’ at the end.
I am trying with the following code.
<%:string.Format("{0:0}",i.discount) %>
this makes 10.0000 to 10.
But is there any way that i can put a ‘%’ after 10??
EDIT:
I am showing data in a table. Some rows have discount value and some rows does not.
SO my query returns null or the discount value.
I only want to show the (%) in those row, that have discount value. I do not want to show only (%) in those rows that does not have any discount value.
Hope it explains the question better.
Try
Alternatively,
Note that this multiplies the number by 100, making 10.00 into 1000%; this may not be what you want.
EDIT: Since you indicate in your comment that this is not what you want, try one of the following:
These should leave the value blank if
i.discountis null.For formatting a single numeric value,
ToStringis marginally more efficient thanstring.Format, becausestring.Formathas a bunch of overhead to parse the format string out of the curly braces and then pass it toToString.