Reputation: 39
I'm retrieving data from my MySQL database and formatting it but I want the cents to be inside a <sup></sup>
tag. Not sure how I go about doing this. I'm using a handler with a StringBuilder to write all the HTML and then filling it into a div. I'm using money data type in the database.
Here is the format:
string.Format("{0:C}", dt.Rows[i]["itemPrice"])
I'm trying to write something like:
$39.99
$39<sup>.99</sup>
Upvotes: 1
Views: 262
Reputation: 9365
I think you need to split it like this:
double p = Convert.ToDouble(dt.Rows[i]["itemPrice"]);
var pi = (int)p;
double pr = (p - pi)*100;
string formattedPrice = string.Format("{0:C0}<sup>.{1:00}</sup>", pi,pr);
Upvotes: 3