Solved

Change datasource for report viewer control programatically

Posted on 2014-09-10
3
253 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now