Link to home
Start Free TrialLog in
Avatar of BeginningWebDesign
BeginningWebDesign

asked on

Convert to decimal problems

Hi
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
Caz
Avatar of mikkelp
mikkelp
Flag of Denmark image


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();


mikkel
Avatar of BeginningWebDesign
BeginningWebDesign

ASKER

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();

Caz
ASKER CERTIFIED SOLUTION
Avatar of mikkelp
mikkelp
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try doing:

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