2014年7月13日 星期日

[RESOLVED] EntityDataSource + GridView not updating and/or deleting!


Hello everybody.


I am trying to use EntityDataSource with GridView and take advantage of its "automatic query generation" feature. 


According to the MSDN docs: "The ListViewFormViewDetailsView,
and 
GridView Web server controls provide automatic read, insert, update, and delete functionality when used with anEntityDataSource control."


After few experiments, while reading data works fine, I can't get Update and Delete to work. 


Please take a look at the code I wrote:


ASPX: http://pastebin.com/svy0yvev


CodeBehind: http://pastebin.com/VHG9Jc0G



Basically, I can see the table with my data. I can see the Edit and Delete buttons. If I click the Delete link, the page reloads and nothing happens. If I click the Edit link, I switch to Edit mode. However, when I press the Update link, the page reloads
and nothing happens. 


I can see the _RowEditing, _RowUpdating and _RowDeleting events are fired. However, I never get to _RowUpdated or _RowDeleted.


Should not EntityDataSource take care of executing the low-level queries? Why is this not happening?


Thanks all for your help!


Cheers,


Gianluca.



For the entity datasource you will need a primary key for the table.it allows you to change the records...i think you may be missed setting of primary key .


Refer bellow post


http://stackoverflow.com/questions/13425270/aspentitydatasource-failing-to-update-or-delete-gridview



沒有留言:

張貼留言