在动态数据自定义页面中,如何检索刚刚更新的对象?

发布于 2024-07-07 19:36:51 字数 191 浏览 8 评论 0原文

我正在使用 ASP.NET 动态数据并有一个自定义页面。

在此页面中,我有一个关于 DetailsView 插入事件的句柄,我想在其中根据最近更新的对象的值执行某些操作。 但是,我无法将事件处理放在相应对象的模型类中,因为它也基于自定义页面中自定义(未绑定)表单元素的值。

如何检索刚刚由DetailsView 更新的对象?

I am using ASP.NET Dynamic Data and have a custom page.

In this page I have a handle on the DetailsView inserted event where I would like to do something based on the value of the recently updated object. However, I can't put the event handling in the model class of the respective object because it is also based on the value of a custom (unbound) form element in the custom page.

How can I retrieve the object that was just updated by the DetailsView?

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

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

发布评论

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

评论(1

清浅ˋ旧时光 2024-07-14 19:36:52

一种半解决方案至少会为您提供通过表单控件更新的字段(不是新的 id 或类似的内容),即访问 DetailsViewInsertedEventArgs 的“Values”属性,如下所示:

protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
    if (e.Exception == null || e.ExceptionHandled)
    {
            String value = (string)e.Values["FIELDNAME"];
            Response.Redirect(table.ListActionPath);
    }
}

One semi-solution that will at least give you the fields that were updated though form controls (not the new id or anything like that though) is to access the 'Values' property of the DetailsViewInsertedEventArgs like so:

protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
    if (e.Exception == null || e.ExceptionHandled)
    {
            String value = (string)e.Values["FIELDNAME"];
            Response.Redirect(table.ListActionPath);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文