CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

Sql Server Reporting Services - Local Report from Business Object Entities

520 Views
Copy Code Show/Hide Line Numbers
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();
}
by Matt Slay
  December 28, 2009 @ 9:43pm
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.

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate