title: ASP.NET - FormView bound to LinqDataSource shows data but won't update database (Updating event fires however)
body: <p>I have a FormView bound to LinqDataSource, that is intended to allow editing of a single product's details, that is selected from a GridView. The LDS has a Where parameter set to point to the GridView control (i.e. a ControlParameter):</p>
  
  <pre><code>&lt;asp:LinqDataSource ID="ldsProduct" runat="server" OnContextCreating="LinqDataSource_ContextCreating"
  EnableDelete="True" EnableInsert="True" EnableUpdate="True" TableName="Products"
  Where="ProductID=@ProductID" OnSelecting="ldsProduct_Selecting" OnUpdating="ldsProduct_Updating"
  OnInserted="ldsProduct_Inserted" OnUpdated="ldsProduct_Updated" OnDeleted="ldsProduct_Deleted"&gt;
  &lt;WhereParameters&gt;
      &lt;asp:ControlParameter Name="ProductID" ControlID="gvProducts" /&gt;
  &lt;/WhereParameters&gt;
  </code></pre>
  
  <p></p>
  
  <p>The FormView <strong>does show</strong> whichever product record I select in the GridView. However when I click Update, <strong>no update is run against the database</strong>.</p>
  
  <p>This is what I have seen:</p>
  
  <ul>
  <li>In the FormView's ItemCommand handler, the Update command happens</li>
  <li>Next, the LDS's Updating event fires however if I look at e.NewObject there is a Product object attached, but it only has it's ProductID set (to the correct value) - all other properties are not set. No doubt this is why the update never hits the database.</li>
  </ul>
  
  <p>I have tried explicitly setting the FormView to Edit mode, and databinding it in the FormView's ItemCommand handler, but it makes no difference, i.e.:</p>
  
  <pre><code>fvProduct.ChangeMode(FormViewMode.Edit)
  fvProduct.DataBind()
  </code></pre>
  
  <p>I just don't get how the FormView is clearly bound to a Product object when it is showing its data but looses it when the Update command runs.</p>
  
  <p>By the way, I am using a custom constructor for the DataContext, but if I replace OnContextCreated with the usual ContextTypeName the problem still happens.</p>