System.InvalidOperationException: Objects added to a BindingSource’s list must all be of the same type.

Problem

I am building a report using ReportViewer RDLC and I’m trying to bind the data. When I try to add my BindingList to the BindingSource I get the following exception:

System.InvalidOperationException: “Objects added to a BindingSource’s list must all be of the same type.”

Here’s the code causing this:

BindingList<Movie> movies = new BindingList<Movie>() { new Movie() { Name = "Pulp Fiction", MPAARating = MPAARating.R }, new Movie() { Name = "The Dark Knight", MPAARating = MPAARating.PG13 } }; this.MovieCollectionBindingSource.Add(movies);

Solution

Set the BindingSource.DataSource to your BindingList.

BindingList<Movie> movies = new BindingList<Movie>() { new Movie() { Name = "Pulp Fiction", MPAARating = MPAARating.R }, new Movie() { Name = "The Dark Knight", MPAARating = MPAARating.PG13 } }; this.MovieCollectionBindingSource.DataSource = movies;

Leave a Comment