We help IT Professionals succeed at work.

convert.ToDecimal

Seven price
Seven price asked
on
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

Comment
Watch Question

Top Expert 2008

Commented:
try this

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

Author

Commented:
does not work do you know how to use format then (value, "##.00") somthing like this not to sure.
Seven priceFull Stack

Author

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
Seven priceFull Stack

Author

Commented:
maybe this will help clarify similar to this problem

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_21038093.html
Top Expert 2008

Commented:
was the code producing errors? because using format will return a string what language are you using?
Seven priceFull Stack

Author

Commented:
yes it is like the form cannot add anything
Full Stack
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

Explore More ContentExplore courses, solutions, and other research materials related to this topic.