How to provide the report viewer a datatable at run time?

Hi,

in my application I need to provide the reportviewer at run time the data to be displayed for the report. Sofar I wrote the following code:

ReportViewer reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
DataSet dataForReport = new DataSet();
dataForReport.ReadXml(@c:DataForReport.xml);
reportViewer.LocalReport.ReportPath=
@C:Documents and SettingsfrankC# projectsDevelopment versionReport1.rdlc;
reportViewer.LocalReport.DataSources.Add
(new ReportDataSource("reportForm",dataForReport.Tables[0]));
dataForReport.Tables[0].Columns[0].ColumnName = "Number";
dataForReport.Tables[0].Columns[1].ColumnName = "Caption";
dataForReport.Tables[0].Columns[2].ColumnName = "Quantity";
dataForReport.Tables[0].Columns[3].ColumnName = "Sales";
dataForReport.Tables[0].Columns[4].ColumnName = "Discount";
dataForReport.Tables[0].Columns[5].ColumnName = "Net";
dataForReport.Tables[0].Columns[6].ColumnName = "Cost";
dataForReport.Tables[0].Columns[7].ColumnName = "Margin";
reportViewForm showreport = new reportViewForm();
showreport.Text = rm.GetString("Carian touch pos report generator", culture);
showreport.ShowDialog();
the data visualizer shows that dataForReport.Tables has the correct column names and also the roww containing the data to display, but the report viewer doesn' display the data, actually no data is displayed.

What am I doing wrong?

hope some one can help me out,

regards

Frank
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories