Feb 10, 2011 08:58 AM|lneville|LINK
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):
<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">
<asp:ControlParameter Name="ProductID" ControlID="gvProducts" />
The FormView does
show whichever product record I select in the GridView. However when I click Update, no
update is run against the database.
This is what I have seen:
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.:
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.
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.