The
Parse
method of
Decimal
explained here
Decimal.Parse Method (String)[
^]
and the
Round
method of
Math
class explained here
Math.Round Method (Decimal, Int32, MidpointRounding)[
^]
can be used as follows:
getdetails.Parameters.Add("@dd_sell", SqlDbType.Float).Value =
Math.Round(decimal.Parse(txt_dd_sell.Text),2,MidpointRounding.AwayFromZero)
By default the
Round
method uses
MidpointRounding.ToEven
enumeration value, which means that if the value to be rounded is
2.555
it will be rounded off to
2.56
and if it is
2.565
then also it will be rounded off to
2.56
as
5
is the mid point. If the
MidpointRounding.AwayFromZero
is used then the above values will be rounded off to
2.56 and 2.57
respectively.