Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

Change datasource for report viewer control programatically

Hi, how can I change the <rsweb:ReportDataSource DataSourceId= property of a report viewer control from
ObjectDataSource1 to ObjectDataSource2?
0
Scarlett72
Asked:
Scarlett72
  • 2
1 Solution
 
Jitendra PatilSr.Software EngineerCommented:
in the code behind you can try the following code as below

reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("datasourcename", source));

"datasourcename" is the name of the data source, you can find it .rdlc file.
source is the variable with data you want to show in the report.

hope this helps.
0
 
Scarlett72Author Commented:
Hi Jitendra, thank you for replying.
So in my .rdlc file,
my Data Source is called:  "RF"
and
my dataset is called dsSalesDelta
So would would the arguments in new ReportDataSource look like this?

reportViewer.LocalReport.DataSources.Add(new ReportDataSource("RF", dsSalesDelta));

Open in new window

0
 
Jitendra PatilSr.Software EngineerCommented:
it would work with
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("RF"));

try this and let me know.

hope this helps.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now