Groups > Databases > MySQL for ASP.NET > Re: Decimal Place with Average




Decimal Place with Average

Decimal Place with Average
Mon, 25 Feb 2008 18:29:28 +000
Hi

 I'm using MySQL, VS2005 and C#


I'm getting the average of the Average column and this is working fine

string sql = "SELECT AVG(Average) FROM studentvillageaverage";

 
I am than displaying this to a label on the webpage with

Session["StudentVillageAverage"] =
MyReader["AVG(Average)"];
            Label4.Text =
Session["StudentVillageAverage"].ToString();

 

The problem I'm having is that  when this is displaying its leaving 4 decimal
points after the number, i.e. 4.000

What do i need to put in to just display 4.0?
Post Reply
Re: Decimal Place with Average
Mon, 25 Feb 2008 23:17:41 +000
You just need to format the string appropriately in your ToString():

Label4.Text =
Session["StudentVillageAverage"].ToString("F1");
Post Reply
about | contact