您如何手动修改与一个FormView绑定的对象? [英] How do you manually modify a bound object with a FormView?

查看:228
本文介绍了您如何手动修改与一个FormView绑定的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用同一个ObjectDataSource一个FormView。当点击保存按钮,我想修改之前被设置为ObjectDataSources Update方法绑定对象中的数据。

I am using a FormView with an ObjectDataSource. When the save button is clicked, I would like to modify the data bound object before it gets set to the ObjectDataSources Update method.

我试过FormView的更新事件,以及对象数据源的更新事件,但我无法弄清楚如何访问数据绑定对象。 FormView.DataItem在这些事件空。

I tried the FormView's Updating event as well as the Object Data Source's Updating event but I can't figure out how to access the data bound object. FormView.DataItem is null in those events.

或者换句话说,我想之前被传递到ObjectDataSource UpdateMethod拦截和修改DataItem的。

Or in other words, I would like to intercept and modify the DataItem before it gets passed to the ObjectDataSource UpdateMethod.

要查看关于我为什么想这样做更详细一点,也有在表单上某些值不能与功能生成数据绑定。其中的一个控件是复选框列表。我使用DataBinding事件来填充检查,但现在我还需要一种方法来更新我的对象,以反映形式的值。也有类似情况的其他控制。

To give a little more detail on why I want to do this, there are some values on the form which can't be databound with the build in functionality. One of the controls is the checkbox list. I am using the DataBinding event to populate the checks, but now I also need a way to update my object to reflect the form values. There are also other controls with similar situations.

推荐答案

你为什么不只是写自己的业务对象(又名ObjectDataSource控件),并包裹原ObjectDataSource的对象吗?然后,您可以拦截任何你想要的,并在途中修改原来的ObjectDataSource控件对象的Save方法。

Why don't you just write your own business object (aka ObjectDataSource), and wrap the original ObjectDataSource object? You can then intercept anything you want, and modify it enroute to the original ObjectDataSource object's Save method.

这篇关于您如何手动修改与一个FormView绑定的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆