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

LVL 9
Seven priceFull StackAsked:
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.

ee_rleeCommented:
try this

prm.Value = Convert.ToDecimal(me.price.text).ToString("0.0##")
0
Seven priceFull StackAuthor Commented:
does not work do you know how to use format then (value, "##.00") somthing like this not to sure.
0
Seven priceFull StackAuthor Commented:
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
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Seven priceFull StackAuthor Commented:
maybe this will help clarify similar to this problem

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_21038093.html
0
ee_rleeCommented:
was the code producing errors? because using format will return a string what language are you using?
0
Seven priceFull StackAuthor Commented:
yes it is like the form cannot add anything
0
Seven priceFull StackAuthor Commented:
Ok to do this I found out such a easier way.

On the Datagird and the tables you have to the Templatecolmn

use the boundcolumn DataFormatString="{0:N}" or any formatt you like to display .

Thanks for trying
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
Web Applications

From novice to tech pro — start learning today.