The Vanilla Thrilla
The Vanilla Thrilla

Reputation: 1995

How do I make the number "0" display in a textbox?

I have a decimal column that contains percentages. I'm converting these so that they display as their whole # counterparts. For example, if a value is 0.35 in the database, I'm displaying it as 35 in the textbox. However, some of the values are 0.00, but don't display in the textbox as 0. In fact, nothing shows up at all.

What would be the proper ToString() format to use to achieve my desired result?

Upvotes: 0

Views: 1267

Answers (2)

Seany84
Seany84

Reputation: 5596

Have you tried .ToString("N0") or am I missing something?

Upvotes: 1

Alpha01
Alpha01

Reputation: 856

See the template below:

String.Format("{0:0.00}", 123.0); 

See http://www.csharp-examples.net/string-format-double/

Thus, you multiply by 100 and display without decimal places. It should work well

Upvotes: 0

Related Questions