title: Update CRM Lookup Field from C#
body: <p>I am attempting to develop an application to allow updates to our CRM database via a gridview.</p>
  
  <p>Everything I have was working till attempting to update a lookup field.</p>
  
  <p>The following is working C# code:</p>
  
  <pre><code>_service = GlobalFunctions.GetServiceAccount();
  GlobalFunctions.User u = (GlobalFunctions.User)Session["UserInfo"];
  
  Entity aspiration = new Entity("tog_aspiration");
  aspiration.Id = new Guid(inputGridView.DataKeys[e.RowIndex].Value.ToString());
  aspiration["tog_nofollrl"] = Int32.Parse(tog_nofollrl);
  _service.Update(aspiration);
  </code></pre>
  
  <p>Now when attempting to add the lookup field to the update it gives me an error.</p>
  
  <pre><code>_service = GlobalFunctions.GetServiceAccount();
  GlobalFunctions.User u = (GlobalFunctions.User)Session["UserInfo"];
  
  Entity aspiration = new Entity("tog_aspiration");
  aspiration.Id = new Guid(inputGridView.DataKeys[e.RowIndex].Value.ToString());
  aspiration["tog_nofollrl"] = Int32.Parse(tog_nofollrl);
  aspiration["tog_techidname"] = new EntityReference("equipment", new Guid(ddlVet.SelectedValue));
  _service.Update(aspiration);
  </code></pre>
  
  <p>Here is the error</p>
  
  <pre><code>Incorrect attribute value type System.String 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
  Exception Details: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Incorrect attribute value type System.String
  </code></pre>