Limit a float value to two decimal places Before it is changed to a string and called by an asp:literal
Posted on 2008-06-19
I am new to C#, so I need to limit a string or float to one decimal places...
float grossYearly = System.Convert.ToSingle(txtField1.Text.ToString());
float newGross = grossYearly/12;
float monthly = System.Convert.ToSingle(txtField2.Text.ToString());
float total = monthly / newGross;
float newTotal = total*100;
string i = newTotal.ToString();
Panel2.Visible = false;
Panel1.Visible = true;
then it is called here...
<asp:Literal id="Literal1" runat="server"></asp:Literal>%
I know there is a simple answer, but there are a lot of issues with testing here, so I need to be sure...Thanks.