I have a table column \"Amount\" of type money. When I am retrieving its value through a store procedure, it returns the value upto 4 decimal places(because of type money).
string.Format("{0:0.00}", your_value);
Read Custom Numeric Formats for detailed instructions on formatting numbers.
value.ToString("0.00");
In C# 6 or later, you can use string interpolation for a somewhat cleaner syntax.
$"{value:0.00}";
Text='<%#Bind("Value","{0:F2}") %>'
You can use Standard Numeric Format Example:
decimal dValue = 1.268;
string sValue = dValue.ToString("N"); // 1.27
Well, I tried it and got the correct result.
Below is the code that I used:
funding.amount= Math.Round(decimal.Parse(dr["Amount"].ToString()), 2).ToString();
//since the amount was of string type, therefore I used the above code. we can also use the below code:
decimal.Round(yourValue, 2, MidpointRounding.AwayFromZero);
http://msdn.microsoft.com/en-us/library/9s0xa85y.aspx
In Leave Event write this code
Double x;
Double.TryParse(txtLocl.Text, out x);
txtLocl.Text = x.ToString("0.00");
After leaving it allowed only two decimal places