Kim
Kim

Reputation: 825

How can I programmatically change the report source of my report viewer

I have created a web application that displays different types of reports. So basically my parameter here is report style. the user will select a report style and then the the report will load according to the selected style.

So I created 7 different designs of report. my question is, how can I programmatically change the report source of my report viewer so that every time the user will select a different report style, the report viewer will call that report.

for example:

If I select STYLE A, the report viewer will load report1. If I select STYLE B, the report viewer will load report2. If I select STYLE C, the report viewer will load report3. and so on...

Upvotes: 1

Views: 894

Answers (2)

lea
lea

Reputation: 101

Try declaring a variable that will accept the ReportStyle parameter. If your webservice has a parameter ReportStyle (String) declare this code on your Visual Basic code.

TypeReportSource - Represents a report source that allows a report document to be instantiated from an AssemblyQualifiedName.

Click here for more info.

Dim typeReportSource As New Telerik.Reporting.TypeReportSource()
Dim ReportStyle as String


if ReportStyle = "A" then
    typeReportSource.TypeName = GetType(SampleReport).AssemblyQualifiedName
    ReportViewer1.ReportSource = typeReportSource
end if

Note that the SampleReport is name of the Report you have created, this is named "Report1" by default.

Upvotes: 1

Lode Vlaeminck
Lode Vlaeminck

Reputation: 944

Hide /unhide elements on the report based on a parameter?

I had a few reports that would show all kinds of different data, and the user had a few parameters i would just hide the Tablix based on an expression.

Like this: parameter has a 3 options view a , b ,c

in tablix for view a go to properties and go to the visabilty menu and add and expression like

Parameter!view.Value = a

this will make the tablix visible.

You can do this for all the views and there repective dataset (just add @view = 'a' in the where clause to stop the query from exicuting when the parameter is not selected)

Hope this helps with the probelem

Upvotes: 0

Related Questions