CipherIS
asked on
ASP.NET - C# - Format string to numeric value
I have a value I am retrieving from a database. I am assigning the value to a text box on my asp.net form. The field in the database is a money value. I want the below result.
Database Value Result Value
0.000000 0.00
I have tried the following
string s = string.Format("{0:c}", rdr["myValue"].ToString()) ;
this.myTextBox.text = s;
and
string s = string.Format("{0:#,0.00}" , rdr["myValue"].ToString()) ;
this.myTextBox.text = s;
But neither works.
Any ideas?
Database Value Result Value
0.000000 0.00
I have tried the following
string s = string.Format("{0:c}", rdr["myValue"].ToString())
this.myTextBox.text = s;
and
string s = string.Format("{0:#,0.00}"
this.myTextBox.text = s;
But neither works.
Any ideas?
are you just getting 0?
String.Format("{0:.##}", rdr["myValue"].ToString()) ;
ASKER
@p_davis - I'm getting "0.0000" as a result for
string s = string.Format("{0:c}", rdr["myValue"].ToString()) ;
I tried string s = string.Format("{0:C}", rdr["myValue"].ToString()) ;
and still getting "0.0000"
string s = string.Format("{0:c}", rdr["myValue"].ToString())
I tried string s = string.Format("{0:C}", rdr["myValue"].ToString())
and still getting "0.0000"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks kaufmed!
you can also try string.Format("{0:C}", rdr["myValue"].ToString())