How to add controls to ReportViewer?

238 views Asked by At

I want to create report with my own controls, But the controls don't appear in the report!

I tried this:

GridView1.DataSource=(Order.GetDailyReport());
   GridView1.DataBind();
   ReportViewer1.Controls.Add(GridView1);

But nothing appeared!

1

There are 1 answers

0
meda On

Read this documentation

Customize the Report Viewer Web Part

But why would you want to add a gridView anyway? it is more meant for controls like the buttons you see on the toolbar.

I think you are trying to build it dynamically because the reportviewer comes with its own table.

You just need to change the way you populate the datasource:

Here is an example of how you would achieve that:

DataTable dt = Order.GetDailyReport();
ReportViewer1.Visible = true;
ReportViewer1.LocalReport.ReportPath = "Report1.rdlc";
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt));

No need for gridview