How to: Bind a Report to an Object Data source (Runtime Sample)

  • 2 minutes to read

The SnapControl supports object data sources that implement any of the following interfaces:

You can use the ObjectDataSource when an object provides data at runtime or a method that returns the data as an object.

Handle the Load event of the application’s main form as shown below to connect the application to an object data source.

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;
using DevExpress.Snap.Core.API;
// ...

class Cars {
    public int ID { get; set; }
    public string Trademark { get; set; }
    public string Model { get; set; }

private void Form1_Load(object sender, EventArgs e) {

    List<Cars> e1List = new List<Cars>();
    e1List.Add(new Cars() { ID = 1, Trademark = "Mercedes-Benz", Model = "SL500 Roadster" });
    e1List.Add(new Cars() { ID = 2, Trademark = "BMW", Model = "530i" });    

    this.snapControl1.Document.DataSources.Add(new DataSourceInfo("Cars", e1List));