Reputation: 11
I'm reading a decimal value from textbox1 and need to insert it to an decimal field in my database.
I having a trouble with "," and "." so first I'm replacing ","s with "." But unfortunately If I enter 1.34 in textbox, it becomes 134.00 in db.
string text = textBox1.Text;
text = text.Replace(",", ".");
decimal total = decimal.Parse(text);
how can I solve this issue?
Upvotes: 1
Views: 3325
Reputation: 57956
What about:
CultureInfo en_us = new CultureInfo("en-US");
decimal value = Decimal.Parse(text, en_us);
Upvotes: 1