I am trying to update a record that has amount paid by customers but on submission i get this error System.FormatException: Input string was not in a correct format.
Server Error in '/' Application.
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:
Line 119:
Line 120: int inserted = 0;
Line 121: float amountavailable = Convert.ToInt32(lblAmountUpdate.Text.Trim());
Line 122: // int amountavailable = lblAmountUpdate);
Line 123: string paymentstatus = ddlpaymentstatus.SelectedItem.Text.Trim();
code
int inserted = 0;
float amountavailable = Convert.ToInt32(lblAmountUpdate.Text.Trim());
// int amountavailable = lblAmountUpdate);
string paymentstatus = ddlpaymentstatus.SelectedItem.Text.Trim();
int amountpaid = Convert.ToInt32(txtamount.Text.Trim());
using (SqlConnection con = new SqlConnection())
{
con.ConnectionString = str;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
}
}
// else
{
// ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('No of Quantity entered is not available in Stock')", true);
}
if (inserted > 0)
{
float updatepayment = amountavailable + amountpaid;
using (SqlConnection con = new SqlConnection())
{
con.ConnectionString = str;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
cmd.CommandText = "UPDATE Sells SET PaymentStatus = @PaymentStatus,AmountPaid=@AmountPaid WHERE SellId = @SellId";
cmd.Parameters.AddWithValue("@PaymentStatus", ddlpaymentstatus.SelectedItem.Text);
cmd.Parameters.AddWithValue("@AmountPaid", updatepayment);
cmd.Parameters.AddWithValue("@SellId", ddltableid.SelectedItem.Text);
con.Open();
inserted = cmd.ExecuteNonQuery();
con.Close();
}
}
}
BindProductsSells();
}
}
}