Reputation: 657
I am trying a to make a report viewer that's gonna show all the reports in the same viewer. I used to make individual report viewer for every RDLC. but that's really a long-process. And kinda stupid.
I have the dataSet in App_Code folder using Table Adapter and i want to take that dataset as the ReportDatasource and use cases for different reports. But I dont know how to. Whatever I got on the internet is doing it using SQL command. But I have the connection and stored procedures ready in DataSet. I want to use that dataset.
Very new to .NET developement, sorry if I am not clear.
Any kind of help is appreciated.
Upvotes: 1
Views: 1105
Reputation: 386
You should do something like:
DataSet ds = SomeMethodToRetrieveDataSet(); // e.g. via DataAdapter
// Set parameters,
ReportParameter[] parameters = new ReportParameter[...];
ReportDataSource reportDataSource = new ReportDataSource();
//match the DataSource in the RDLC
reportDataSource.Name = "ReportData";
reportDataSource.Value = ds.Tables[0];
// Addparameters to the collection
reportViewer1.LocalReport.SetParameters(parameters);
reportViewer1.LocalReport.DataSources.Add(reportDataSource);
reportViewer1.DataBind();
Upvotes: 1