The purpose of the ObjectDataSource component is to provide business objects data to data items in a declarative manner. The ObjectDataSource.DataSource property should be the assembly qualified name or the Type of the data access layer (class), where the reporting engine will use System.Reflection to create the instance of the class by using its default constructor, and to execute its method specified by the ObjectDataSource.DataMember property.

When you configure the ObjectDataSource component the settings below are obligatory to avoid runtime error due to failed data retrieval:

  • Visual Studio is a 32-bit application, so the report designer is restricted to x86 mode even on x64 platforms, which prevents the ObjectDataSource Wizard from discovering any types from x64 assemblies. The solution is to use different platform configurations: for "Debug" builds it is best to use "Any CPU", while for "Release" builds you can use "x64" instead.

  • Some Data Items (Graph, Map) will call the constructor or the data retrieval method of your business object during design-time. This is required in order to obtain the data, process it, and create a live preview of the data item. For this reason the business object used to feed the data item with data should be accessible during design-time, otherwise the data item will not be able to generate a live preview of the data.

Creating the DataSource

  1. Open Visual Studio and create a new Class Library.

  2. Add the following piece of code from How to: Bind to a BusinessObject.

    Example

    class Product
    {
        //properties
    }
    
    [DataObject]
    class Products
    {
       //objects
     }
  3. Build the project and close it.

Configuration

For security reasons the ObjectDataSource can resolve only types that are declared either in the current report's assembly or in AssemblyReferences element nodes in Telerik.Reporting section of application configuration file. During report processing, the ObjectDataSource component tries to resolve its type and if it is not listed in these two places, an exception will be thrown.

  • Configuration in Visual Studio Report Designer:

    In this case, you will need to add a reference to the Class Library project or to the dll which contains the data source definition.

  • Configuration in the Standalone Report Designer:

    1. Open the project folder of the Class Library -> bin -> Debug and copy the dll file.

    2. Paste it at the installation folder of the Report designer (C:\Program Files (x86)\Progress\Telerik Reporting [Version]\Report Designer).

    3. Open Telerik.ReportDesigner.exe.config file with a text editor.

    4. Add an AssemblyReferences in Telerik.Reporting section of application configuration file:

      <?xml version="1.0"?>
      <configuration>
          <configSections>
              <section name="Telerik.Reporting" type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting" allowLocation="true" allowDefinition="Everywhere" />
          </configSections>
          ...
          <Telerik.Reporting>
            <assemblyReferences>
              <add name="yourAssemblyName"/>
            </assemblyReferences>
           </Telerik.Reporting>
         ...
      </configuration>

    The additional attributes like version, culture and publicKeyToken are not mandatory, because the .NET runtime can resolve the assembly only by its name.

    After modifying the configuration file the application needs to be restarted so the new configuration settings will be read again.

Using the ObjectDataSource in the Report

  1. Open the Report Designer and create a new report.

  2. Navigate to Data and click Object Data Source.

  3. Select from the Available data source types and follow the Wizard instructions until the process is completed.

Configuration in the Report Viewers

  1. Add the reference which contains the data source to the project.

  2. Open the project's configuration file and add the same assembly reference like the one required for the Standalone designer.

In this article
Not finding the help you need?