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

Parameters: can't perform '=' on String and Int

2 Answers 349 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Digital Man
Top achievements
Rank 2
Digital Man asked on 12 May 2008, 11:48 PM
I'm finally playing with Telerik Reporting. I have a WinForm with the ReportViewer control. I have a report setup. I added a int type parameter called UserID to the parameter collection of the report. I created a filter expression of UserID_FK = the UserID parameter (from the dropdown). In the code I set the param using

reportViewer1.Report.ReportParameters.Add("UserId", Telerik.Reporting.ReportParameterType.Integer, value.ToString());

It only accepted a string as a parameter.

Not clear on the best way to do this.

2 Answers, 1 is accepted

Sort by
0
Milen | Product Manager @DX
Telerik team
answered on 13 May 2008, 01:51 PM
Hi Dan Duda,

In the current implementation of the expression engine, if both values of the operands in the comparison are of different types , false is returned. So you need to provide a value in the appropriate type.

The Add method you are using is intended to add a parameter with an expression as value. Actually, in previous versions of the product only expressions could be used as value for the parameters. This method is left in the API for backwards compatibility reasons.

Now if you need to add a report parameter programmatically, you can use the same code as the generated from the report designer. Something like:

            Telerik.Reporting.ReportParameter parameter = new Telerik.Reporting.ReportParameter();
            parameter.Name = "UserID";
            parameter.Type = Telerik.Reporting.ReportParameterType.Integer;
            parameter.Value =
value;

             reportViewer1.Report.ReportParameters.Add(parameter);

Or even more simpler, to use the other constructor of the report parameter:

            Telerik.Reporting.ReportParameter parameter = new Telerik.Reporting.ReportParameter(
                   
"UserID",
                   
Telerik.Reporting.ReportParameterType.Integer,
                    value
);

             reportViewer1.Report.ReportParameters.Add(parameter);

However, in your case you have defined and used (in the filter) the parameter at design time. So all you need to do in the win application is to access the parameter and set it's value. Something like:

            reportViewer1.Report.ReportParameters["UserID"].Value = value;

For more information on report parameters, please review the help article Report Parameters.

Let us know if you need any further assistance.
 
Kind regards,
Milen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Digital Man
Top achievements
Rank 2
answered on 13 May 2008, 01:54 PM
Ah, thank you!
Tags
General Discussions
Asked by
Digital Man
Top achievements
Rank 2
Answers by
Milen | Product Manager @DX
Telerik team
Digital Man
Top achievements
Rank 2
Share this question
or