I got myself a BiningList
Of student (Entity Framework created class).
I just want to feed my RDLC
report from that instead of using DataSet
or stored procedures.
This class contains multiple properties like :
string Name;
string FamilyName;
string Mid;
DateTime Birth;
...
Any one can help me with that?
Form
and from the Toolbox put a Report Viewer
control on the form.BindingSource
will be added to the form.Double click on Form
to handle Load
event and add this code to the event handler:
var data = db.Students.ToList();
this.studentBindingSource.DataSource = data;
this.reportViewer1.RefreshReport();
Put a ReportViewer
control on a form and handle Load
event of form and write this code:
var data = db.Students.ToList();
var reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
reportDataSource1.Name = "DataSet1";
reportDataSource1.Value = data;
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
this.reportViewer1.LocalReport.ReportEmbeddedResource = "ReportSample.Report1.rdlc";
this.reportViewer1.RefreshReport();
reportDataSource1.Name
should be name of DataSet
in your report definition. To see it, open the report and in Report Data window, under Datasets node see the dataset name.
If you set report using ReportEmbeddedResource
, then the property should be name of the report in embedded resources. If it starts with default name space of project and continue with folder names if your report is in a folder in solution explorer and at last the name of report.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With