Formatting currency for a label

Hi I am trying to get the subtotal query to show as a #.## value. Now I am getting four digits to the right of the decimal. I have tried various permutations of below, but I get either an error or no change.
void CalcTotal()
    {
        //Todo
        //declare and initialize connection object to connect to the database
        SqlConnection conn = new SqlConnection(
            WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        SqlCommand cmd; //declare a command object that will be used to send commands to database.
        conn.Open();
        cmd = conn.CreateCommand();

        cmd.CommandText = "Select Sum(Quantity*Listprice) " +
            "From Shopcartline as SHL inner join Song as S on SHL.SongID = S.SongID " +
            "Where ShopcartID = " + Session["shopCartID"];
        cmd.CommandType = CommandType.Text;

        //declare an SqlDataReader variable
        SqlDataReader dataReader;
        dataReader = cmd.ExecuteReader();

        if (dataReader.HasRows)
        {
            dataReader.Read();
            lblTotal.Text = dataReader.GetValue(0).ToString();
          lblTotal.Text = String.Format("{0:C2}",lblTotal.Text);<----Here
        }
        else
        {
            lblTotal.Text = "";
        }
        conn.Close();
    }

Open in new window

sukotto100Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alfred A.Commented:
Hi,

Try this,

lblTotal.Text = lblTotal.Text.ToString("f2")
0
Alfred A.Commented:
Hi,

Or, you can try this if you are formatting currency,

lblTotal.Text = lblTotal.Text.ToString("C2")
0
Om PrakashCommented:
Try:

string a = dataReader.GetValue(0).ToString();
lblTotal.Text = a.ToString("#0.00"));
0
guru_samiCommented:
Try this:

Double amount =(Double) dataReader.GetValue(0);
lblTotal.Text = amount.ToString("c2");

Or
string amount = dataReader.GetValue(0).ToString();
lblTotal.Text = Convert.ToDouble(amount).ToString("c2");<----Here
0
lazyberezovskyCommented:
I think that will be enough:
lblTotal.Text =String.Format("{0:C2}", dataReader.GetValue(0));

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.