Seems like you just want first to decimals, not rounding.
I mean 0.98 for 0.98677, not 0.99. If it is the case, use following function
public string getValueUpto2Decimal(string value)
{
if (value.Contains(".")) {
value += "00";
} else {
value += ".00";
}
return value.Substring(0, value.IndexOf(".") + 3);
}
This is purely based on string functions.
Though I seriously have a doubt that you get a string value from database. If you get a
double
from database, then just use
ToString()
to pass it to the function.