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

Difficulty updating a Report Parameter

3 Answers 341 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ebenezer
Top achievements
Rank 1
Ebenezer asked on 04 Jun 2015, 06:42 PM

Hello!
I'm currently upgrading Telerik reporting in my application from version 5.1.11.928 to version 8.2.14.1204. I am using Visual Studio 2010, using C#.

 

I'm encountering a problem with a report parameter using a sqlDataSource. At first, I was encountering a problem because an arraylist was being used in a parameter (as an ansistring). This caused an error with XML serialization. So I realized that an arraylist wouldn't work anymore. However, the query its using is relying on accepting a collection of values.
    (e.g. (Where number.ID IN (@ValueType) )

 

I saw that I can change the parameter to accept multiple values from:
    http://www.telerik.com/help/reporting/designing-reports-parameters.html

 

However, I can't seem to get it to work correctly. For some extra context I have also changed the collection to a hashset<int>.
The report parameters are being set with code that uses the reportviewer.
Example:
var genericReport = new GenericReport();
genericReport.ReportParameters["ValueType"].Value = hashValueGenerator("Selector");
//hashValueGenerator returns a hashset of integers based upon its selector
//This used to be an arrayListGenerator

From there, the code would then take the report that was generated and add it to the reportSource. (This part works fine.)
I believe I am setting up my value type incorrectly to accept the new collection I'm creating.

 Here is the parameter as it existed before the upgrade:
    Name: @ValueType
    DbType: AnsiString
    Value: =Parameters.ValueType.Value

 

This is my attempted fix to my problem:
    Name: @ValueType
    DbType: Int32
    Value: //Shown below as created in the Report Parameter Editor
    //Only the bolded (non-default) changes are being displayed
    //Organized to look like pseudocode, but I am using the editor
    //Quotes are for readability, they are not used in the actual editor boxes
Report Parameter{
AvailableValues {
    DataSource = sqlDataSource,
    //The same as shown as the data source on the report designer.
    ValueMember= "=Parameters.ValueType.Value"}
MultiValue= true,
Name= ValueType,
Text= ValueType,
Type= Integer,
Visible= true
}

I get the following error in my Report Viewer: "Missing or invalid parameter value. Please input valid data for all parameters."
Can anyone give me any insight as to what I'm doing wrong?

Thank you very much!

3 Answers, 1 is accepted

Sort by
0
Accepted
Stef
Telerik team
answered on 05 Jun 2015, 08:54 AM
Hello Ebenezer,

Please check the details how to map a SQL parameter to report parameter in Using Parameters with the SqlDataSource component and SqlDataSource wizard (steps4 and 5). Check also the required settings for creating a multivalue report parameter - Using Multivalue Parameters.

since multivalue report parameters are evaluated as arrays of objects, the value sent from the parameter must be handled properly in the data retrieval method (SQL query). My post in this forum thread provides further details how to handle multivalue parameters.

Regards,
Stef
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Ebenezer
Top achievements
Rank 1
answered on 09 Jun 2015, 02:20 PM

Hello!

Thank you for your reply and the link to the extra resources I missed. It ended up leading me to the correct solution, though I will say that some of the documentation ended up misleading me a bit.

I ended up calling the ToArray() Method on the HashSet. (This is an extension method on IEnumberable). This fixed my problem.

 

Apparently a multivalue parameter cannot accept an IEnumberable Collection despite the online documentation being listed as being able to do so. (At least in the version I'm using). At this link:
http://www.telerik.com/help/reporting/designing-reports-parameters.html
Under the section Value it states:     "When a parameter accepts multiple values (MultiValue=True), you can set the value by programmatically assigning an IEnumerable of the allowed types." This does not, however, appear to actually be the case.

Thank you for your help!

0
Stef
Telerik team
answered on 10 Jun 2015, 07:31 AM
Hi Ebenezer,

I am glad to hear you found a solution, and will appreciate it if you post the report settings and the used data model to test the issue with using IEnumerable collections.

Regards,
Stef
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Ebenezer
Top achievements
Rank 1
Answers by
Stef
Telerik team
Ebenezer
Top achievements
Rank 1
Share this question
or