Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox changes decimal value

Status
Not open for further replies.

damann

Technical User
Jul 19, 2000
114
US
Hello all,

I'm a little stumped on something I'm working on. I'm using 1.0 of .NET by the way.

Ok, I'm pulling decimal values from my DB and passing the values to a textbox. This decimal in the DB is long at times, sometimes .0000003 (for example); but when a value like this one is passed to the textbox it displays it as 3E-7 or something like that. How can I get this thing to display as how it is in the database: .0000003? Please let me know...


Thanks,
Damann
 
The most probable reason is that it is being passed to the textbox as an Integer. If you passed it as a string then it would be OK.

If you wish you can paste your code and we'll have a look to see if that is the case.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
I am converting it back to a string that's what's wierd about it...

private decimal foo; -- declaring var.

This section of the code enters user input var into the DB.
------
if(fooTextBox.Text!="")
foo = Convert.ToDecimal(fooTextBox.Text.Text);

updateDB.Parameters["@vFoo"].Value = foo;
-----

This section pulls it back and displays it back in the textbox. This is where it does that wierd conversion.
-----
foo = Convert.ToDecimal(sqlRdr["FOO_FIELD"].ToString());

fooTextBox.Text = foo.ToString();
-----
 
foo = Convert.ToDecimal(sqlRdr["FOO_FIELD"].ToString());
Why to you convert it to a decimal here? It is already stored as a decimal in your db so I think you should only have to convert it to a string here. e.g.

Code:
foo = sqlRdr["FOO_FIELD"].ToString;
fooTextBox.Text = foo;

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
I'm doing this instead guys...


fooTextBox.Text = foo.ToString("0.000000");


This fixes the problem...


Thanks,
Damann
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top