asp.net - Issue with String.Format output -
i trying display @ 2 decimal places in smallcurrency field being pulled sql database. can see in image below using format specifiers limit number of decimal places rendered controls on screen.
however can see in image below fields displaying 4 decimal places (despite database containing records holding 2 decimal places). have attempted variety of different format specifiers omitting string.format has had no effect.
am missing obvious here or strange happening work?
you shouldn't call tostring()
on value inside format
. counteracts format completely, turning value string (with 4 decimal places in case), , ignores other formating.
if want leave textbox blank (as per comments) when field empty, surround assignment if statement.
if productinformation.rows(0)("monthlyprice") isnot dbnull.value me.txtmonthlyprice.text = string.format("{0:0.##}", productinformation.rows(0)("monthlyprice")) else me.txtmonthlyprice.text = "" end if
Comments
Post a Comment