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"))%>&nbsp; </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; } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -