ObjectDataSource::TypeName Property


Gets or sets the name of the class that the ObjectDataSource object represents.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

property String^ TypeName {
	String^ get();
	void set(String^ value);

Property Value

Type: System::String^

A partially or fully qualified class name that identifies the type of the object that the ObjectDataSource represents. The default is an empty string ("").

To create an instance of the object that the ObjectDataSource control binds to, the control uses reflection to load the type that is identified by the type name at run time. Therefore, the value of the TypeName property can be a partially qualified type for code that is located in the Bin or App_Code directories or a fully qualified type name for code that is registered in the global assembly cache. If you use the global assembly cache, you must add the appropriate reference to the assemblies section of the Machine.config or Web.config file.

The type must have a default constructor, unless you handle the ObjectCreating event to create an instance of it yourself. An instance of the type is created for each call to the Select, Update, Insert, and Delete methods, if the methods on the type are member methods. An instance is not created if the methods are static (Shared in Visual Basic). If the type implements the IDisposable interface, the Dispose method is called before the object is destroyed.

The following code example demonstrates how a GridView control can display data by using an ObjectDataSource control on a Web Forms page. The ObjectDataSource identifies a partially or fully qualified class name with its TypeName property and a method that is called to retrieve data with its SelectMethod property. At run time, the object is created and the method is called using reflection. The GridView control enumerates through the IEnumerable collection that is returned by the SelectMethod property, and displays the data.

No code example is currently available or this language may not be supported.

The following example shows the class that the TypeName property value refers to.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top