Solved

Change datasource for report viewer control programatically

Posted on 2014-09-10
3
269 Views
Last Modified: 2014-09-15
Hi, how can I change the <rsweb:ReportDataSource DataSourceId= property of a report viewer control from
ObjectDataSource1 to ObjectDataSource2?
0
Comment
Question by:Scarlett72
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Expert Comment

by:jitendra patil
ID: 40316744
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
 

Author Comment

by:Scarlett72
ID: 40317298
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
 
LVL 13

Accepted Solution

by:
jitendra patil earned 500 total points
ID: 40318698
it would work with
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("RF"));

try this and let me know.

hope this helps.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question