Here is my updated code snippet for the GridView
After clicking on the update button, the gridview is not being updated and instead reverting back to its previous value. However, the delete option is working correctly.
Id = ((Label)GridView1.Rows[e.RowIndex].FindControl("lblDealerId")).Text;
Name = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDealer_Name")).Text;
Address = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDealer_Address")).Text;
City = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtCity")).Text;
Pincode = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDealer_Pincode")).Text;
string cs = ConfigurationManager.ConnectionStrings["dbcs"].ConnectionString;
SqlConnection con = new SqlConnection(cs);
SqlCommand cmd = new SqlCommand("sp_update_dealer", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@dealer_id", SqlDbType.NVarChar).Value = Id;
cmd.Parameters.Add("@dealer_name", SqlDbType.NVarChar).Value = Name;
cmd.Parameters.Add("@dealer_address", SqlDbType.NVarChar).Value = Address;
cmd.Parameters.Add("@dealer_city", SqlDbType.NVarChar).Value = City;
cmd.Parameters.Add("@dealer_pincode", SqlDbType.NVarChar).Value = Pincode;
//GridView1.EditIndex = -1;
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();