I'm trying to round decimal values with two decimal places, e.g. I have 57,328385899814471243042671610 and I want 57.33.
for (int i = 1; i < cobtable.Columns.Count; i++) //loop para preencher a linha das percentagens
{
Decimal a = (Decimal)cobtable.Rows[2][i];
Decimal b = (Decimal)cobtable.Rows[0][i];
cobtable.Rows[3][i] = Decimal.Divide(a, b) * 100;
// Decimal c = (Decimal)cobtable.Rows[3][i];
// c = (a / b) * 100;
// c = Math.Round(c,2);
Response.Write((Decimal)cobtable.Rows[3][i]);
Response.Write("*");
}
GroupGrid.DataSource = cobtable;
GroupGrid.DataBind();
the c
variable gives me on response.write()
the correct value but in the grid it doesn't show the same value, it shows 57,328385899814471243042671610. What am I doing wrong?
Use following method:
second parameter is no of decimal places