ObjectDataSource Source Object Example
Illustrates a custom middle-tier business object that can be used with an ObjectDataSource control.
The following code example illustrates a custom middle-tier business object that can be used with an ObjectDataSource control. This topic also illustrates an example ASP.NET page that uses the business object as the source for an ObjectDataSource control. The page includes a GridView control and a DetailsView control that are bound to the ObjectDataSource control.
To use the code, you can create a code file in your Web application's App_Code subdirectory and copy the code into the file. The business object will then be compiled dynamically and included as part of your Web application. Alternatively, you can compile the business object and place it in the Bin directory of an ASP.NET application or in the Global Assembly Cache (GAC). For more information on the App_Code and Bin directories, see Shared Code Folders in ASP.NET Web Site Projects.
The example requires a connection string for the sample Northwind database on a SQL Server. The connection string must be defined in the <connectionStrings> element of the application's configuration file. The connectionStrings section might look like the following example:
<configuration>
<system.web>
<connectionStrings>
<add
name="Northwind"
connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;" />
</connectionStrings>
</system.web>
</configuration>