I'm putting together a REALLY simple report for my WinForms app.
I use an object data source. Here's the class:
--------------------------------------------------------------------------
public class ProjectEnergyUsageReportValues
{
private double defaultUsage;
public double DefaultUsage
{
get { return defaultUsage; }
set { defaultUsage = value; }
}
private double oldUsage;
public double OldUsage
{
get { return oldUsage; }
set { oldUsage = value; }
}
private double newUsage;
public double NewUsage
{
get { return newUsage; }
set { newUsage = value; }
}
}
--------------------------------------------------------------------------
No brainer. I have an embedded RDLC file. When I created the RDLC file, I
added the class to my data sources window, and dragged the properties
(DefaultUsage, OldUsage, NewUsage) to the "data fields" section. I see the
three of them listed there.
When I added the ReportViewer control to my form, I used the smart tag to
associate it with the RDLC file I created.
Here's what I'm doing in my report form constructor:
--------------------------------------------------------------------------
reportViewer1.ProcessingMode = ProcessingMode.Local;
ProjectEnergyUsageReportValues reportValues = new
ProjectEnergyUsageReportValues();
reportValues.DefaultUsage = 5.0;
reportValues.OldUsage = 6.0;
reportValues.NewUsage = 7.0;
BindingSource bindingSource = new BindingSource();
bindingSource.DataMember = "ReportValues";
bindingSource.DataSource = reportValues;
reportViewer1.LocalReport.DataSources.Add(new
ReportDataSource("ProjectedEnergyUsage_ReportValue s", bindingSource));
--------------------------------------------------------------------------
And finally, in the form load event:
--------------------------------------------------------------------------
this.reportViewer1.RefreshReport();
--------------------------------------------------------------------------
When I run the app and open the form, I see the report layout fine, but
there's no data.
Any idea why?