Convert to decimal problems

Posted on 2005-05-16
Last Modified: 2010-04-16
can anyone help with this problem, I'm trying to add a value to a textbox but cannot seem to get the datareader to convert the value into a decimal.

tbBudget.Text = RdrGetCustomerDetails["intBudget"].ToString("c");
I keep receiving the error: No overload for method 'ToString' takes '1' arguments

Any help would be appreciated on this
Question by:BeginningWebDesign
    LVL 4

    Expert Comment


    Hi Caz

    that's because ToString() doesn't take any argument.

    you could probably do this:

    tbBudget.Text = RdrGetCustomerDetails["intBudget"].ToString();

    or if you want the decimal as a decimal.

    // int index = 42 // your decimal value's column-index
    tbBudget.Text = RdrGetCustomerDetails.GetDecimal(index).ToString();


    Author Comment

    Hi mikkel

    The code below works, but how can I display only 2 decimal places after the . i.e 20.00 as it currently displays 20.0000
    tbBudget.Text = RdrGetCustomerDetails["intBudget"].ToString();

    LVL 4

    Accepted Solution

    ahh. I get it, sorry for my being slow in the uptake..

    one way:

    tbBudget.Text = RdrGetCustomerDetails.GetDecimal(index).ToString("c");


    tbBudget.Text = string.Format("{0:c}", RdrGetCustomerDetails.GetDecimal(index));

    the reason why your RdrGetCustomerDetails["intBudget"].ToString("c") didn't work, was because RdrGetCustomerDetails["intBudget"] isn't of type "decimal". You could fix it like this: ((decimal)RdrGetCustomerDetails["intBudget"]).ToString("c");

    LVL 3

    Expert Comment

    Try doing:

    tbBudget.Text = Convert.ToDecimal(RdrGetCustomerDetails["intBudget"]).ToString("0.00");

    Author Comment

    Thanks mikkelp

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    Problem with C# 1 44
    Detect file exist or not 3 37
    Any reason why this might be bad? 7 27
    import issue in bit values 3 31
    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now