Err :
Error:System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseSingle(String value, NumberStyles options, NumberFormatInfo numfmt) at System.Single.Parse(String s, NumberStyles style, NumberFormatInfo info) at System.Single.Parse(String s) at _Default.GridView1_RowCommand(Object sender, GridViewCommandEventArgs e) in d:\running\Default.aspx.cs:line 138
my coding is:
cmd = new SqlCommand("select SUM(ISNULL(amount,0)) AS total from amt", con);
dr = cmd.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
if (dr[0] != DBNull.Value)
{
amount =
Convert.ToSingle(dr[0]);
}
else
amount = 0;
float f = amount + float.Parse(TextBox1.Text); //error ?
dr.Close();
cmd =
new SqlCommand("update amt set amount='" + txamount.Text + "',total='" + f + "' where id ='" + lbid.Text + "'", con);
cmd.ExecuteNonQuery();
GridView1.EditIndex = -1;
Response.Write("Updated Successfully");
bindgrid();
}
else
{
dr.Close();
}