Reputation: 7884
I'm new to MS reporting. What I'm trying to achieve is to make a simple report which would be filled from a DataTable
(made programmatically). The idea is to assing data for each page to values from DataRow
. I.e. report page 1
would get its TextBox
values from DataTable.Rows[0]
, report page 2
would display values from DataTable.Rows[1]
etc. Number of pages = number of DataRows
.
I've coded a WinForms app that gets a DataTable
from SQL and filters it based on parameters supplied by user and then displays a Report.
Then I created an empty dummy DataSet
called ComplianceFormDataSet
which contains all the field names I will need further. Then I made an .rdlc
, added a TextBox
to it with this expression:
=Fields!CustomerCode.Value
Here's the logic behind passing the data to ReportViewer:
DataTable MainDataTable = new DataTable();
MainDataTable.Columns.Add("CustomerCode", typeof(string));
MainDataTable.Rows.Add("Blah1");
MainDataTable.Rows.Add("Blah2");
ReportDataSource MainDataSource = new ReportDataSource("ComplianceFormDataSet", MainDataTable);
MainReportViewer.LocalReport.DataSources.Clear();
MainReportViewer.LocalReport.DataSources.Add(MainDataSource);
MainReportViewer.RefreshReport();
When I build this a get a report with one page saying "Blah1"
. How do I make it render two pages: one with "Blah1"
and the second with "Blah2"
? Thank you.
Upvotes: 4
Views: 22461
Reputation: 7884
Ok, I figured this out:
Pretty obvious, isn't it?
Upvotes: 12