Language: C#
Sql Server Reporting Services - Local Report from Business Object Entities
private void GenerateReport() { ViewModel viewModel = new ViewModel(); int quoteNo = 1000; viewModel.LoadData(quoteNo); ReportViewer1.Reset(); ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report2.rdlc"); ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Quote", new ArrayList { viewModel.Quote.Entity })); ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Distributor", new ArrayList { viewModel.Quote.Entity.DistributorEntity })); ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("User", new ArrayList { viewModel.Quote.Entity.UserEntity })); ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Devices", viewModel.DevicesWithName.ToList())); ReportViewer1.LocalReport.Refresh(); }
Tags:
Description:
After HOURS of trial and error and tons of web surfing, I have learned how you can rather easily pass Business Object entities (i.e. from the West Wind Web Tools for Asp.Net LinqToSql Business Objects) into a local report (.rdlc) in Reporting Services. In the code sample, a single entity can be converted to a suitable report Data Set format with the ArrayList class, and the "viewModel.DevicesWithName.ToList()" gives a report Data Set that I display in a Tablix control on the report.
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

