简体   繁体   English

GridView-如何手动更新EntityDataSource?

[英]GridView - How to manually update EntityDataSource?

I have a GridView bound to an EntityDataSource. 我有一个绑定到EntityDataSource的GridView。 Automatic Updates/Inserts/Deletes are enabled, and these operations function correctly. 启用了自动更新/插入/删除,并且这些操作正常运行。

However, I'd like to make multiple edits before commiting anything to the database. 但是,我想在将任何内容提交到数据库之前进行多次编辑。 (vs. committing each row as soon as the Update button is clicked.) When the user finally clicks a Save button, all the page's edits shall be committed. (与单击“更新”按钮后立即提交每一行相对。)当用户最终单击“保存”按钮时,所有页面的编辑都将被提交。 eg myEntityModel.SaveChanges(); 例如myEntityModel.SaveChanges();

This link says to copy the data to a new table and bind the GridView to that. 链接表示将数据复制到新表并将GridView绑定到该表。 Would that be the recommended approach for Entity Framework (4.0), or is there a better way? 这是实体框架(4.0)的推荐方法,还是有更好的方法?

Thanks! 谢谢!

Yes, its right way to do that. 是的,这样做的正确方法。 look here for some interesting discussion on this topic. 在这里寻找有关此主题的一些有趣的讨论。 I mean calling savechanges at last, till that time modified entities will be persisted virtually. 我的意思是说,最后要调用savechanges,直到那时修改后的实体将被虚拟保留。

note: Batch update is not currently done by EF, even you say save changes multiple queries will hit to database. 注意:EF当前不进行批量更新,即使您说保存更改,多个查询也将命中数据库。 There are other way around to achieve this. 还有其他方法可以实现此目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM