title: Asp.net gridview update with a dropdownlist from the database
body: <p>this is the error am getting: EQMT' has a SelectedValue which is invalid because it does not exist in the list of items.
  Parameter name: value'</p>
  
  <p>I am trying to update the data on the gridview with a dropdownlist below is the code.</p>
  
  <pre><code>protected void GridviewRecord_RowUpdating(object sender, GridViewUpdateEventArgs e)
      {
          int RECORD_ID = Convert.ToInt32(GridviewRecord.DataKeys[e.RowIndex].Value.ToString());
          GridViewRow row = (GridViewRow)GridviewRecord.Rows[e.RowIndex];
          Label lblID = (Label)row.FindControl("lblID");
  
  
          DropDownList EQMT = (row.FindControl("EQMT") as DropDownList);
  
  
          GridviewRecord.EditIndex = -1;
          using (SqlConnection con = new 
         SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString))
          {  //SqlConnection con = new SqlConnection("ConnectionString");
              SqlCommand cmd = new SqlCommand("spEnginehours_Update", con);
              try
              {
                  if (con.State != ConnectionState.Open)
                  {
                      con.Open();
                  }
              }
              catch
              {
               throw;
              }
  
  
                  cmd.Parameters.AddWithValue("@EQMT", EQMT.Text);
  
                  cmd.ExecuteNonQuery();
                  con.Close();
                  LoadRecord();
  
          }
      }
  
  
  
  }
  </code></pre>
  
  <p>}</p>