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

How to pass in array as parameter from SilevrLight ReportViewer

1 Answer 248 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
RAVINDRA
Top achievements
Rank 1
RAVINDRA asked on 27 Jun 2011, 08:11 PM
Hi

I am trying to pass an int array from SilverLight Codebhind throigh ReportParameters to the Report. I am getting the follwoing error when i run the app.
"An error has occured while processing Report 'Report2'
An error has occured while resolving 'Objectdatasource1 datasource: Object must implement IConvertible'".

The fllowing is the xaml codebhind
public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }
 
        private void RepViewer_RenderBegin(object sender, Telerik.ReportViewer.Silverlight.RenderBeginEventArgs args)
        {
            args.ParameterValues["productIds"] = new object[] {2, 3};
        }
    }


The following is the method the object data source is bound to using dataMember propery
public IQueryable<Product> GetProductsByIds(int[] productIds)
        {
            return this.ObjectContext.Products.Where(prod => productIds.Contains(prod.ProductID));
        }


Please help me how do i do it.

Thanks in advance
Ravindra

1 Answer, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 28 Jun 2011, 08:37 AM
Hello RAVINDRA,

You get this error because multi-value parameters pass their values as object[], but the corresponding argument of your method is int[]. There is no automatic conversion between object[] and int[] - hence the error. To correct this, declare your argument as object[] instead, and convert it to a int[] programmatically in the method body if necessary.

All the best,
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
RAVINDRA
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or