Solved

Change datasource for report viewer control programatically

Posted on 2014-09-10
3
261 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
  • 2
3 Comments
 
LVL 12

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 12

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 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