Link to home
Start Free TrialLog in
Avatar of Seven price
Seven priceFlag for United States of America

asked on

convert.ToDecimal

yes i have a price text field in which when i add the price it loads into a datagrid. But what i want if a user adds 2.99 ok that shows up but if a user adds 2 i want it to show  up as 2.0 but the way i am doing it does not seem to work.
prm = New SqlParameter(@price", SqlDbType.Decimal)
prm.Direction = ParameterDirection.Input
prm.Value = Convert.ToDecimal(me.price.text)
cmd.parameters.Add(prm)
 
Any suggestions

Open in new window

Avatar of ee_rlee
ee_rlee
Flag of Philippines image

try this

prm.Value = Convert.ToDecimal(me.price.text).ToString("0.0##")
Avatar of Seven price

ASKER

does not work do you know how to use format then (value, "##.00") somthing like this not to sure.
prm.Value = Convert.ToDecimal(me.price.text) we have some how get this value to convert me.price.text with 0.0 ToString does not work because we are not really converting to a string this is still numeric.
but if you know the syntex with Format to rerwright this that would help
maybe this will help clarify similar to this problem

https://www.experts-exchange.com/questions/21038093/Using-Format-function.html
was the code producing errors? because using format will return a string what language are you using?
yes it is like the form cannot add anything
ASKER CERTIFIED SOLUTION
Avatar of Seven price
Seven price
Flag of United States of America 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