使用 DetailsView 控件更新记录时如何检索只读值?

发布于 2024-08-27 04:15:52 字数 301 浏览 4 评论 0原文

我正在使用详细信息视图控件来更新记录,但在这种特殊情况下,只有一个字段可以在多个字段中进行更改。我的对象的更新方法将所有字段作为参数。当详细信息视图的更新方法触发时,只读字段的值(呈现为标签的值)在 e.NewValues 集合中不可用。

当前,当详细信息视图进行数据绑定时(在 objectdatasource 选择的事件处理程序中),我正在获取对对象的引用,将其存储在会话中,并在更新触发时手动将条目添加到 e.NewValues 集合中。它有效,但似乎有点严厉。

那么,是否有更好的方法将只读值返回到我的更新方法中?或者有更好的方法来完成这个任务吗?

I'm using a detailsview control to update a record, however in this particular case there's only one field that can be changed out of a many. The update method for my object takes all fields as parameters. When the detailsview's updating method fires, the values for the readonly fields (those rendered as a Label) are not available in the e.NewValues collection.

I'm currently grabbing a reference to the object when the detailsview is databound (in the objectdatasource selected event handler), storing it in session and manually adding entries to the e.NewValues collection when updating fires. It works but seems kind of heavy handed.

So, is there a better way to get the read only values back into my update method? Or is there a better way of doing this altogether?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巾帼英雄 2024-09-03 04:15:52

还应该有一个 OriginalValues 集合,它可能包含只读值的集合...您能验证一下吗?

HTH。

There should be an OriginalValues collection too, which may have the collection of readonly values... can you verifiy that?

HTH.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文