This is a migrated thread and some comments may be shown as answers.

Help with passing parameter from silverlight

5 Answers 143 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sam Cartner
Top achievements
Rank 1
Sam Cartner asked on 18 Mar 2010, 12:59 PM
Hi, iv been trying to pass a parameter to the ReportViewer report from my silverlight client. I came across this http://blogs.telerik.com/blogs/posts/09-12-07/programmatic_initialization_of_report_parameter_values_in_telerik_reporting_silverlight_viewer.aspx
but cannot get it to work. Keep getting error 'expects parameter @TenantsID which was not supplied'

I have a parameter in the report called @TenantsID which is an Integer. Below is my code(vb) to replace it.

Public Sub New(ByVal strReportName As StringByVal intReportParam As Integer
        InitializeComponent() 
 
        mstrReportName = strReportName 
        mintReportParam = intReportParam 
         
        AddHandler Me.ReportViewer1.RenderBegin, AddressOf ReportViewer1_RenderBegin 
 
    End Sub 
 
    
    Private Sub ReportViewer1_RenderBegin(ByVal sender As ObjectByVal args As Telerik.ReportViewer.Silverlight.RenderBeginEventArgs) 
         
    args.ParameterValues("@TenantsID") = "2" 
        
 
    End Sub 

Thanks

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 18 Mar 2010, 02:12 PM
Hi Sam,

If you have a report parameter of Type=Integer with name TenantsID, then most likely the error is coming from a datasource parameter TenantsID that you're not setting a value to. Select the SqlDataSource adapter from the report designer right click on it and select Configure. Then pass through the steps and make sure that you set a Value for the datasource parameters you have. It would seem that you want to wire the datasource parameter with the report parameter, so your expession should look like in the attached screenshot.

Kind regards,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sam Cartner
Top achievements
Rank 1
answered on 18 Mar 2010, 03:11 PM
Thanks for the reply steve. I have tried this and i am now getting the following error

'one or more parameters are not set or have invalid values.'

I have created a value as per your screenshot and also tried the 2 lines of code and both result in the error.

args.ParameterValues("@TenantsID") = 2
args.ParameterValues("TenantsID") = 2
0
Steve
Telerik team
answered on 18 Mar 2010, 03:49 PM
Hello Sam,

We believe the error is self-explanatory - if you have another parameter and you're not setting its Value, you will receive this exception. If it is OK to have a null value for a parameter then alter that specific report parameter value AllowNull property and set it to True.

Sincerely yours,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sam Cartner
Top achievements
Rank 1
answered on 18 Mar 2010, 03:53 PM
The only parameter i have is the @TenantsID which im setting. I have even tried setting it to be value '1' which used to work but does now not.

However though i have been messing around with parameter values, which seemed to be holding (in the screen shot) could this be a problem?

any way to remove these?

Thanks again

0
Accepted
Steve
Telerik team
answered on 19 Mar 2010, 04:16 PM
Hello Sam Cartner,

The only reason that you might get such repeating values is if you have several report parameters with the same name. Although the report parameter's editor would not detect duplicate names by the time of adding them, you would have errors at runtime and you should always use unique names for your parameters.
Open your report.designer.vb class and in the InitializeComponent method look for how many report parameters have been serialized. If TenantsID is the only one you need and you have more, please delete them. Also a good idea (now that you know what you need) is to recreate the report from scratch and see if the same problem occurs.
If you are still having problems and since we do not know what you've done with your report while messing around with it, providing us with a runnable sample in a support ticket would be the best way to proceed.

Kind regards,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
Sam Cartner
Top achievements
Rank 1
Answers by
Steve
Telerik team
Sam Cartner
Top achievements
Rank 1
Share this question
or