我有以下情况:
我的商务舱:
public class Foo
{
public String A {get;set;}
public DateTime B {get;set;}
// .. and other properties like
public String Intern {get;set;}
}
我将该项目绑定到 Editmode 中的 DetailsView。(我绑定了一个包含单个 Foo 对象的 List,因为我记得我只能将 IEnumerable<> 类绑定到 DetailView)绑定是通过 ObjectDataSource 完成的
<asp:ObjectDataSource ID="odsEditfoo" runat="server"
SelectMethod="GetFooAsList"
TypeName="mynamespace.FooMethods"
DataObjectTypeName="mynamespace.Foo"
oninserting="odsEditfoo_Inserting" onupdating="odsEditfoo_Updating"
UpdateMethod="UpdateFoo">
<SelectParameters>
<asp:Parameter Name="A" Type="Int32" DefaultValue="-1" />
<asp:Parameter DefaultValue="-1" Name="type" Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>
更新方法看起来像
public void UpdateFoo(Foo item)
{
// save changes ...
}
在 DetailsView 中完成的更改存在于项目实例中。不幸的是,我无法显示每个属性,例如属性 Intern。由于该项目绑定到 DetailView 我有所有必要的信息。回发发生时,项目中所有未显示的属性都将丢失。
我正在寻找一种我以前从 LinqDataSource 获得的方法,在那里我有一个更新事件,它允许我访问绑定的对象,在本例中是 foo 的实例,以更改属性。我似乎无法在 ObjectDataSource 的更新事件中弄清楚如何做到这一点。我必须做些什么来解决这个问题?