views:

787

answers:

3

I have just create a very basic Dynamic Data web application using Entity Framework, and when I click the edit command from the GridView, to open a Details view, edit some fields, and click the Update link, nothing happens.

My question is what could cause this update to do nothing and are there any tips for diagnosing it?

MORE INFO It seems the EntityDataSource 'hides' exceptions. I have found more than one reason for the update or insert operation not completing, but I had to use a SQL trace and trap the command being sent. Running that command manually gives a quick and visible SQL error. Why this doesn't find its way to my UI is a mystery.

A: 

So ... Write the code? I'm confused. What's your question?

Noon Silk
The whole point of dynamic data with scaffolding is to not write CRUD code. Any code I write would interfere with a system developed by a large team of experts over a long time, and is tested and reliable.
ProfK
+2  A: 

In general, anytime you are debugging or developing a Dynamic Data website, one should goto the Site.master file and set the ScriptManager's attribute EnablePartialRendering to false:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="false"/>

This will make exceptions more apparent that otherwise seem to be swept under the rug because of the use of Update Panels that wrap around the DetailsView, FormViews and GridViews on the List/Edit/Insert/Details/ListDetails page templates.

I think the real problem you are running into has something to do with error handling and update panels. When debugging in IE, do you see a little exclamation point in the bottom left of the screen? If so, click on it and you will see the javascript error (Sys.WebForms.PageRequestManagerServerErrorException) that has occured because of the unhandled exception.

For more on this, check out ScottGu's Blog on the topic.

@Aaron's comment: that is too early to capture the errors he is referring to. I think, in this scenario, he wants to handle the Updated event because the EntitydataSource will not actually throw an exception until after it gives this event's handlers a chance to run: (MSDN):

If an error occurs when changes are persisted to the data source, the Updated event is raised and the Exception property of the EntityDataSourceChangedEventArgs object is set to the returned Exception. If you handle the exception in the Updated event handler, set the ExceptionHandled property to true. This prevents the exception from being raised again. When you specify a value of false for the ExceptionHandled property, the EntityDataSource re-raises the exception.

Merritt
A: 

If I am trying to update data from a DetailsView control I'd mostly rely on code behind techniques. I believe there is an ItemCommand fired when you click on any of the DetailView's standard buttons. So inside of these events you have to figure out which button fired the event and take necessary action.

But since your detailsview sits inside a gridview edit template, I suggest you wire the events manually; incorporate them in your markup manually.

...And the update you click is on the DetailsView and not the gridview; so remember to cancel the gridview's editing mode and rebind the gridview.

Hope this helps !!!

deostroll