I have Textbox which takes decimal values. I have written Keypress event to enter decimal numbers. But when I am trying to convert the value in the textbox to Decimal format to store in database, it is only converting it to Integer.
I am trying to convert text to decimal as follows:
dr["Total Amount"] = Decimal.Parse(txtTotalAmount.Text.ToString());
well I am using the above code with the datagridview.
Kindly check your
DataTypeof Total Amount in your table. if you are using SQL Server and want to store decimal value then you have to use money or decimal according to your need.Note:
DECIMAL(2,2)andDECIMAL(2,4)are different data types. This means that 11.22 and 11.2222