I am getting some percent values from a database and I need to format them to have the correct thousands seperator, number of decimal places and a percent sign on the end.
I tried this:
string text = "105,3"; //example, formatting like database input
string format = "#,##0.##";
e.Row.Cells[i].Text = double.Parse(text).ToString(format);
Weirdly this returns 1053,00%
. How do I make it so it returns 105,30%
? (The decimal comma is because the system locale is german, so it's how it is supposed to be)
edit: replacing the comma with a period results in 10530.00%
. Nothing makes sense to me anymore.
edit2: the float.Parse()
actually works just fine. the ToString()
messes everything up. I played around with using different cultural settings and format strings (switching comma and period) but it only makes it worse again.