ASP.NET 2.0: Specifying an instance of an object for an ObjectDataSource

被刻印的时光 ゝ 提交于 2019-12-05 19:43:18

Create an event handler for the ObjectCreating event on the ObjectDataSource.

You can assign the instance to using the ObjectDataSourceEventArgs property

protected void ObjectDataSource1_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
{
    e.ObjectInstance = myObject;
}

Wire this event up in the markup too

<asp:ObjectDataSource OnObjectCreating="ObjectDataSource1_ObjectCreating" />
Dillie-O

As I just discovered in my own question here, items stored in the Application Cache are going to pass themselves as a reference for use. You may consider storing your data there (or potentially in the Session as well) and pass items that way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!