ObjectDataSourceEventArgs.ObjectInstance Property
Assembly: System.Web (in system.web.dll)
/** @property */ public Object get_ObjectInstance () /** @property */ public void set_ObjectInstance (Object value)
public function get ObjectInstance () : Object public function set ObjectInstance (value : Object)
Property Value
The business object the ObjectDataSource uses to perform data operations; otherwise, a null reference (Nothing in Visual Basic), if a null reference (Nothing in Visual Basic) is passed to the ObjectDataSourceEventArgs.This section contains two code examples. The first code example demonstrates how to use an ObjectDataSource control with a business object and a GridView control to retrieve and display information. The second code example provides the example basic business object that the first code example uses.
The following code example demonstrates how to use an ObjectDataSource control with a business object and a GridView control to retrieve and display information. In this example, as in many real-world scenarios, it might not be possible nor appropriate to use a default instance of the business object with the ObjectDataSource control. In this example, the ObjectDataSource cannot successfully call the default constructor because it will throw an exception. In some cases, the default constructor might be protected and in others it might not initialize the business object to a desired state. Whatever the reason, you can create an instance of the business object yourself and set the instance to the ObjectInstance property of the ObjectDataSourceEventArgs object that is passed to the handler. This is the business object instance that the ObjectDataSource will use to perform its work.
The following code example demonstrates the example basic business object that the preceding code example uses.
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.