c# - Decimal conversion
I have a promlem with decimal conversion in C#. I enter some numbers in a text field. And the software adds zeros to the number everytime the number is updated.
Any ideas on thath. The code is as follows:
{code}decimal fastShipFee = System.Convert.ToDecimal(((TextBox)e.Item.Cells[7].FindControl("editFastShipFee")).Text.Replace(",",".").ToString());{/code}
I use the above conversion to read from a text box in a grid cell.
Later on I call the function below:
{code}currentRetailPolicy.masterUpdate(countryName, fixOrderHandling , costPerUnit, costPerLb, costPerSqFt , costMarkUp, activeCountry, fastShipFee);
{/code}
The function writes to a an access database table.
{code}public void masterUpdate(string countryName, decimal fixOrderHandling, decimal costPerUnit, decimal costPerLb, decimal costPerSqFt, decimal costMarkUp, bool activeCountry, decimal fastShipFee)
{
dbOp myDbOp7 = new dbOp();
cmdMasUpt = new System.Data.OleDb.OleDbCommand();
string commandText ="Update sellerRetailPolicy Set fixOrderHandling =" +
fixOrderHandling + ", costPerUnit =" + costPerUnit + ", costPerLb =" + costPerLb +
", costPerSqFt=" + costPerSqFt + ", markUp=" + costMarkUp + ",activeCountry = " + activeCountry + ", fastShipFee = " + fastShipFee + " Where (customer_ID = " + sid +
") AND country_name = '" + countryName + "'";
HttpContext.Current.Response.Write (commandText);
HttpContext.Current.Response.End();
cmdMasUpt.CommandText = commandText;
cmdMasUpt.Connection = myDbOp7.dbCon;
myDbOp7.dbOpen();
System.Data.OleDb.OleDbTransaction trnsact = myDbOp7.dbCon.BeginTransaction();
cmdMasUpt.Transaction = trnsact;
try
{
cmdMasUpt.ExecuteNonQuery();
trnsact.Commit();
}
catch (Exception e)
{
string ErrorMsg = e.Message.ToString();
trnsact.Rollback();
rError callError = new rError();
callError.errorDisplay(ErrorMsg);
}
finally
{
myDbOp7.dbClose();
}
}{/code}
Any ideas how to resolve that.

