Entities may have been modified or deleted since entities were loaded. Db Update Concurrency Exception: Store update, insert, or delete statement affected an unexpected number of rows (0).Here is how I did it for my same case and modified the names to mimic your classes.In other words, just change // This function receives an object type that can be a view model or an anonymous // object with the properties you want to change.Our goal is to extend this example to allow for the user to delete products via the Grid View.
public int Update(object entity) public static object To Type You should use the.Once we add deleting support to the Grid View, the Grid View will automatically supply this parameter value, using the value of its property added, the Grid View s smart tag now contains the Enable Deleting option. As discussed in An Overview of Inserting, Updating, and Deleting, this causes the Grid View to add a Command Field with its .As Figure 4 shows, when the page is visited through a browser a Delete button is included. Figure 4: Each Grid View Row Now Includes a Delete Button (Click to view full-size image) Upon clicking a Delete button, a postback occurs, the Grid View assigns the Figure 5 depicts this interaction graphically.The results are then returned as either a Data Set or Data Reader, depending on the value of the control s value has been specified, the Enable Inserting, Enable Editing, or Enable Deleting option in the corresponding data Web control s smart tag will become available.
To illustrate this, let s take an example from the table and a Grid View that renders this data.The Sql Data Source control supports the same operations, but the approach is different, and this tutorial shows how to configure the Sql Data Source to insert, update, and delete data.