No data appearing in my report

G

Guest

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_ReportValues", 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?
 
G

Guest

*BUMP*

I guess I should have mentioned that I'm creating a simply report using the
new WinForms ReportViewer control.

Anyways, I'd really like some help with this issue.... Anyone?!
 
G

Guest

FYI:

As it turns out, the problem was my data source. When you're using an
object data source, you must specify a collection (implements IEnumerable) of
objects. I was just passing in one object. When you think about it, it
makes sense.

Anyway, yay, it works now!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top