开发者

How to Bind a ReportViewer to an IEnumerable<T>

开发者 https://www.devze.com 2023-03-14 00:23 出处:网络
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 (ObjectDataSou

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消