如何仅跟踪中继器asp.net中更改的值
我有一个包含数据的可编辑嵌套中继器。我用它来显示数据并保存用户更新的数据。 我想检测用户修改了数据的特定单元格/行,以便我可以仅更新数据库中的特定行,而不是再次保存所有数据。 有没有办法解决这个问题。Javascript 或服务器端代码哪种是最好的技术?
Resource country etc | Week1 Week2 Week3 | Total
ABC XYZ 10 15 20 45
这就是中继器的结构。 中间一个(显示可编辑资源工作时间的周)是嵌套中继器。 只能在嵌套转发器中更改值。 我在隐藏字段中为每个资源维护唯一的 ID。
你能建议我一些方法来实现这个功能吗?
I have a editable nested repeater containing the data.I use it for showing the data and also for saving the data which is updated by the user.
I want to detect particular cell/row for which the data has been modified by the user so that I can update only that particular row in the database instead of saving all the data again.
Is there a way to work this out.Which would be the best technique to use ,Javascript or server side code ?
Resource country etc | Week1 Week2 Week3 | Total
ABC XYZ 10 15 20 45
This is the repeater structure.
Middle one (Weeks showing hours worked by resource which is editable) is the nested repeater.
Values can only be changed in the nested repeater.
I maintain unique ID's for each resource in the hidden field.
Can you suggest me some ways to achieve this functionlity ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这通常由您的 ORM 处理,但如果您愿意,您可以自己实现。这个想法被称为“更改跟踪”,基本上通常所做的就是从数据库中检索记录,然后将已知的检索值与新值进行比较,然后再次保存。
根据您的并发策略,您还可以使用发送到客户端的原始值的哈希值,可能放置在隐藏字段中,然后您可以检查数据库中的原始值与当前值,以免意外覆盖其他人的值变化。
This is normally handled by your ORM, but you can implement it yourself if you like. The idea is called 'change tracking', and basically what's commonly done is to retrieve the record from the database, then compare known retrieve values to the new values before saving it again.
Depending on your concurrency strategy, you also might use a hash of the original values that were sent to the client, placed in a hidden field perhaps, which you can then check original vs. currently in the database in order to not accidentally overwrite someone else's changes.