c# - Trying to convert object to integer to show as a percentage, but it only shows 0 -
i have object
value in data type decimal(18,2)
. try convert integer
data value show 0 although 6.
i want show value 0.06 6. can me why still shows 0?
<td class="line_table_td" style="text-align: center;"> <%#getpercentage(eval("value"))%> </td> public decimal getpercentage(object value) { var perc = convert.toint32(value); return(perc); }
if should decimal value, converting integer drop fractional portion.
convert decimal first, multiply 100 "percentage" representation.
public decimal getpercentage(object value) { var percentage = convert.todecimal(value) * 100; return percentage; }