Wednesday, October 27, 2010

The report data source object must be of the type System.Data.DataTable, System.Collections.IEnumerable, System.Windows.Forms.BindingSource, or System.Type.

Problem:
"The report data source object must be of the type System.Data.DataTable, System.Collections.IEnumerable, System.Windows.Forms.BindingSource, or System.Type." when you add an object to ReportDataSource.value

Solution:
If you are adding a business object then you should create a BindingList collection class, and then put the single business object into the collection and set that as the data source.

For example, lets say you have business class Product. Create a class public class ProductCollection : BindingList {}
note: BindingList is part of the System.ComponentModel namespace.

4 comments:

  1. Thanks, very helpful.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Can you provide an example code?

    ReplyDelete

There was an error in this gadget