When i am inserting decimal value into database from GridView then below error is coming.
Input string was not in a correct format.
decimal b_rate = Convert.ToDecimal(row.Cells[7].ToString());
value is 0.5428
protected void btn_Save_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GVballist.Rows)
{
if ((row.FindControl("chkRows") as CheckBox).Checked)
{
string Id = row.Cells[2].Text;
decimal b_rate = Convert.ToDecimal(row.Cells[7].ToString());
this.Insert(Id, b_rate);
}
}
}
private void Insert(string Id, decimal b_rate)
{
using (SqlCommand cmd = new SqlCommand("[Sp_Update_BBINVOICE]", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@DID", Id);
cmd.Parameters.AddWithValue("@B_Rate", b_rate);
cmd.Parameters.AddWithValue("@CustomerID", DDLcus.SelectedValue);
con.Open();
cmd.ExecuteNonQuery();
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", " alert('Pack saved sucessfully');", true);
con.Close();
}
}