Skip to content

Commit 1376568

Browse files
Create object-must-implement-iconvertible.md (#1095)
1 parent be4d9f9 commit 1376568

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Object must implement IConvertible
3+
description: "Learn why and when the 'Object must implement IConvertible' is thrown and how to resolve it in Telerik Reporting"
4+
type: troubleshooting
5+
page_title: MultiValue Parameter in ObjectDataSource Throws Error IConvertible
6+
slug: object-must-implement-iconvertible
7+
tags: ObjectDataSource, MultiValue, ReportParameter
8+
ticketid: 1612711
9+
res_type: kb
10+
---
11+
12+
## Environment
13+
<table>
14+
<tbody>
15+
<tr>
16+
<td>Product</td>
17+
<td>Progress® Telerik® Reporting</td>
18+
</tr>
19+
</tbody>
20+
</table>
21+
22+
23+
## Description
24+
25+
I have created an [ObjectDataSource]({%slug telerikreporting/designing-reports/connecting-to-data/data-source-components/objectdatasource-component/overview%}) component whose data method has a parameter that is of type `List<int>`. When I try to preview the report, I am met with the below error in place of the [data item]({%slug telerikreporting/designing-reports/connecting-to-data/data-items/overview%}) using said `ObjectDataSource`.
26+
27+
## Steps to Reproduce
28+
29+
1. Create an `ObjectDataSource` whose data method expects a list/array of primitive type as one of its parameters.
30+
1. Create a `MultiValue=True` [Report Parameter]({%slug telerikreporting/designing-reports/connecting-to-data/report-parameters/overview%}) and set its value to be passed to the parameter of the `ObjectDataSource`
31+
1. Set the value of the report parameter and preview the report.
32+
33+
## Error Message
34+
35+
`An error has occurred while resolving data source: Object must implement IConvertible`
36+
37+
## Cause
38+
39+
The `Multivalue` Report Parameters always return `Object[]`. As the received `Object[]` cannot be converted to `List<type>`, the corresponding `ObjectDataSource` Parameters cannot be correctly mapped to the Report Parameters.
40+
41+
## Solution
42+
43+
Change the type of the `ObjectDataSource` Parameters using `MultiValue` to `Object[]` in one of the following ways:
44+
45+
- Through the [ObjectDataSource Wizard]({%slug telerikreporting/designing-reports/report-designer-tools/desktop-designers/tools/data-source-wizards/objectdatasource-wizard%})
46+
- Through the code behind:
47+
48+
````CSharp
49+
new Telerik.Reporting.ObjectDataSourceParameter("UserNames", typeof(object[]), "= Parameters.UserNames.Value"),
50+
````
51+
52+
53+
## See Also
54+
55+
* [Using Parameters with the ObjectDataSource Component]({%slug telerikreporting/designing-reports/connecting-to-data/data-source-components/objectdatasource-component/using-parameters-with-the-objectdatasource-component%})
56+
* [Using Multivalue Parameters]({%slug telerikreporting/designing-reports/connecting-to-data/report-parameters/using-multivalue-parameters%})

0 commit comments

Comments
 (0)