Gets or sets the name of the class that the ObjectDataSource object represents.
Assembly: System.Web (in System.Web.dll)
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 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 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.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS" Assembly="Samples.AspNet.CS" %> <%@ Page language="c#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>ObjectDataSource - C# Example</title> </head> <body> <form id="Form1" method="post" runat="server"> <asp:gridview id="GridView1" runat="server" datasourceid="ObjectDataSource1" /> <asp:objectdatasource id="ObjectDataSource1" runat="server" selectmethod="GetAllEmployees" typename="Samples.AspNet.CS.EmployeeLogic" /> </form> </body> </html>
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.