Override decimal ToString() method
- by Jimbo
I have a decimal datatype with a precision of (18, 8) in my database and even if its value is simply 14.765 it will still get displayed as 14.76500000 when I use Response.Write to return its value into a webpage.
Is it possible to override its default ToString method to return the number in the format #,###,##0.######## so that it only displays relevant decimal places?
UPDATE
I'm assuming that when one outputs number on a page like <%= item.price %> (where item.price is a number) that the number's ToString method is being called?
I'm trying to avoid having to change every instance where the value is displayed by defaulting the ToString() format somehow.