使用 ASP.NET 动态数据进行多实体编辑
我有一个基于“ASP.NET 动态数据域服务 Web 应用程序”模板的 ASP.NET 动态数据 4 Web 应用程序。
一个关键的用户要求是用户可以选择编辑多行,然后将批量提交到数据库进行更新。这些行将根据其底层对象状态突出显示。例如,“已添加”将为绿色,“已删除”将为红色,“已修改”将为黄色。我对批量更新不太感兴趣,因为我感兴趣的是能够同时使多个对象处于编辑状态。用户可以单击主“保存”按钮并将所有更改发送到数据库,或者可以取消并回滚所有更改。
据我在经过广泛而令人沮丧的搜索后能够确定的是,这不是使用动态数据可能实现的场景。
有没有人能够实现这种行为,如果是的话,请您指出正确的方向以弄清楚如何做到这一点。
谢谢,亚历克斯。
I have an ASP.NET Dynamic Data 4 web app based on the "ASP.NET Dynamic Data Domain Service Web Application" template.
A key user requirement is that the user can choose to edit multiple rows and then submit the bulk to the database for updating. The rows would be highlighted according to their underlying object state. For example, "Added" would be green, "Deleted" would be red, and "Modified" would be yellow. I'm not so interested in batch updates as I am in being able to have more than one object in an edit state simultaneously. The user can click a master "Save" button and have all changes sent to the database, or can cancel and have all changes rolled back.
As far as I have been able to determine after extensive and frustrating searching, is that this is not a scenario that is possible using Dynamic Data.
Has anyone been able to achieve this behaviour and if so, could you please point me in the right direction to figure out how to do it.
Thanks, Alex.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ASP.NET 动态数据是用于快速构建简单数据驱动的 Web 应用程序的 API。但速度是用灵活性换来的。据我所知,这对于动态数据是不可能的(我只使用了 .NET 3.5 + futures 项目中的版本,所以我不确定这在 .NET 4.0 中发生了多大变化)。
问题在于动态数据基于直接与 EF 的数据绑定以及基于检索到的实体自动生成字段和列。每个执行的更改都直接在 EF = in DB 中执行。您的要求要求您将数据保留在会话中,并且仅当用户触发保存按钮时才执行更改。这需要应用程序中的另一层并使用其他方式绑定数据。您将需要
ObjectDataSource
或自定义绑定。我不确定这将如何适应应用程序的“动态”性质。您可以轻松地为必须支持这一点的每种实体类型编写单独的代码。ASP.NET dynamic data is API to build very quickly simple data driven web application. But the quickness is exchanged with flexibility. This is not possible with Dynamic data as I know (I used only version in .NET 3.5 + futures project so I'm not sure how much this changed in .NET 4.0).
The problem is that dynamic data are based on databinding directly to EF and autogenerating fields and columns based on retrieved entities. Each executed change is directly executed in EF = in DB. Your requirement demands that you keep data in the session and execute changes only if user triggers the save button. That require another layer in your application and using other way to bind data. You will either need
ObjectDataSource
or custom binding. I'm not sure how this will play with "dynamic" nature of the application. You can easily end up writing separate code for each entity type which have to support this.我有同样的需求,只是我不需要更新多个表。也许对你来说有点晚了,但我找到了这个网页来阅读。我的页面刚刚开始开发。
http://msdn.microsoft.com/en- us/library/aa992036(v=vs.100).aspx
托德
I have the same need, only I do not need to update multiple tables. It is a little late for you perhaps, but I found this web page to read. My page is just beginning its development.
http://msdn.microsoft.com/en-us/library/aa992036(v=vs.100).aspx
Todd