title: How to prevent exception when updating the gridview?
body: <p>I have a gridview and the content data inside gridview is called from a stored procedure,but whenever i want to update the gridview row content an Exception appears.
  The update code is as below:</p>
  
  <pre><code>protected void Grid_Updating(object sender, GridViewUpdateEventArgs e)
      {
          SqlCommand cmd = DataProvider.GenerateCommand("Update_HowzeEducation_SP", CommandType.StoredProcedure);
          cmd.Connection.Open();
  
          cmd.Parameters.Add("@FieldName", SqlDbType.NVarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
          cmd.Parameters.Add("@DegreeId", SqlDbType.Int).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
          cmd.Parameters.Add("@SchoolName", SqlDbType.NVarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text;
          cmd.Parameters.Add("@StudyCityDescribtion", SqlDbType.NVarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text;
          cmd.Parameters.Add("@Average", SqlDbType.Decimal).Value = decimal.Parse(((TextBox)GridView1.Rows[e.RowIndex].Cells[5].Controls[0]).Text, CultureInfo.InvariantCulture);
          cmd.Parameters.Add("@FinishLevelDate", SqlDbType.Date).Value = Convert.ToDateTime(((TextBox)GridView1.Rows[e.RowIndex].Cells[6].Controls[0]).Text.Trim());
          cmd.Parameters.Add("@ThesisTitle", SqlDbType.NVarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[7].Controls[0]).Text;
          cmd.Parameters.Add("@Describtion", SqlDbType.NVarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[8].Controls[0]).Text;
          cmd.Parameters.Add("@HowzeEducationId", SqlDbType.Int).Value = GlobalVariables.HowzeEducationId;
  
          cmd.ExecuteNonQuery();
  
      }
  </code></pre>
  
  <p>And the exception is :
  <strong>Failed to convert parameter value from a String to a Int32.</strong>
  This message comes up in the last line of the code.</p>
  
  <p>I will be thankfull for any usefull help.</p>