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?
 
Seven priceConnect With a Mentor Full 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
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
 
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
All Courses

From novice to tech pro — start learning today.