How to Bind a ReportViewer to an IEnumerable<T>
I´m starting to use MS-Report and I would want to know if it is possible to bind a ReportViewer component directly to an IEnumerable collection, instead of creating a DataSourceControl (ObjectDataSource, EntityDataSource, SqlDataSource, etc...), in a similar way as we do with databound components (using the Datasource property instead of DataSourceID). I know that the ReportViewer don´t have a "DataSource" property, but I´m wondering if there is a suchlike way.
In my case I´开发者_JAVA技巧m using a nTier application with repository pattern and Entity Framework (POCO EF 4.1).
Thanks!
You need to create a reportDataSource for your report (using the designer). You will asked for a name of the reportDateSource and a type (the type of the entities of your IEnumerable collection)(lets suposse you named id 'test' and your datatype is Client)
ReportDataSource reportDataSource = New ReportDataSource("test", listofclients);
localreport.DataSources.Add(reportDataSource);
That's all.
精彩评论