ObjectDataSource and MultiValue Parameter

11 posts, 0 answers
  1. Ulrich
    Ulrich avatar
    23 posts
    Member since:
    Dec 2008

    Posted 25 Aug 2010 Link to this post

    Hello,

    I have a (hopefully) easy question/problem:

    I am using an objectdatasource to populate a Telerik Report. This is working fine. Now I want to change one of the parameters of the select function in the DataSource to accept a multi-value parameter (multiple ints), but regardless what I try as type (object, object[], int[]), I always get the error that the following error during creation of the report:

    An error has occured while processing Table 'crosstab1':
    An error has occured while resolving 'MyObjectSource' data source: Ein Objekt muss IConvertible implementieren.
    The last error translates to "an object has to implement IConvertible".

    I even changed the parameter of the function in the objectdatasource to type IConvertible, with no luck.

    What am I doing wrong to get multivalue parameters to work?

    BTW: I am still at Q1 2010 release and have not yet updated to Q2

    best regards

    Ulrik
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 31 Aug 2010 Link to this post

    Hi Ulrich,

    The DataSource Components don't work out of the box with a MultiValue Report Parameter since the current implementation is based on ADO.NET and does not allow you to pass a collection of values (set, array). Thus, the SqlDataSourceParameter accepts only single values corresponding to the SqlDataSourceParameter.DbType property. Although this is a known limitation of ADO.NET and not a problem of our product, we're currently working on possible solution for it and it would be part of the upcoming Q2 SP1.

    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
  3. DevCraft banner
  4. steve
    steve avatar
    8 posts
    Member since:
    Jul 2012

    Posted 21 Feb 2011 Link to this post

    Hello Steve,

    has this problem been solved now? If so, how should the signature of business object's method look like? (I am using Q3 2010)
  5. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 24 Feb 2011 Link to this post

    Hi Steve,

    Such scenario would work automatically since the latest Q2 SP1 2010 release, namely the following item: Fixed: SqlDataSource cannot map database parameter to multivalue report parameter.

    Best wishes,
    Steve
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  6. steve
    steve avatar
    8 posts
    Member since:
    Jul 2012

    Posted 18 Mar 2011 Link to this post

    Hi Steve,

    thank you for your response, but I still don't know how the signature of the business object's method should look like. I have a report parameter "ids" which has the MultiValue flag set to true, and the Type set to Int. Now I want to bind the value of this parameter to a business object's method's parameter. I have tried these signatures, but either didn't work for me (the same exception as in the first post):

    class BusinessObject {
      GetItems(int[] idsBusiness) { ... }
      GetIetms(object[] idsBusiness) { ... }
      GetItems(object idsBusiness) { ... }
    }
    Which type of the parameter idsBusiness should I use in order to bind the report's parameter "ids" to it?

    P.S.: I am using Q3 2010
  7. Michael
    Michael avatar
    4 posts
    Member since:
    Nov 2009

    Posted 16 May 2011 Link to this post

    I'm using the latest, but with MySql and an ObjectDatasource and I get the "IConvertable" error. How do I do a multi-value to an "In"?
  8. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 23 Sep 2011 Link to this post

    Hi. I am having the same problem/question as described above.

    My report is using an ObjectDataSource with the following datamember:

    public static Collection<ReportCommonMatrixDataContract> GetSmokingStatusReport(DateTime fromDate, DateTime toDate, string schemaType, int? fromAge, int? toAge, string gender)

    This works fine when the parameter "gender" is a normal dropdown. When I turn on multivalue for this parameter I get the following error:

    An error has occurred while resolving 'objectDataSource1' data source: Object must implement IConvertible.

    What type should my datamember "gender" be to make this work?

    Regards, Roy
  9. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 27 Sep 2011 Link to this post

    Hello Roy,

    You get this error because multi-value parameters pass their values as object[], but the corresponding arguments of your method are not arrays. There is no automatic conversion between object[] and regular type (e.g. string) - hence the error. To correct this, declare your argument as object[] instead, and convert it to a string[] or whatever your correct type is programmatically in the method body if necessary.

    Best wishes,
    Steve
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  10. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 04 Oct 2011 Link to this post

    Thanks, this works fine.

    I am having the same problem with my nullable integer parameters fromAge and toAge. It works fine when the parameters are set to null, but when they have a value for instance 10, then I get the error:
     
    An error has occurred while processing Chart 'chart1':
    Specified cast is not valid.

    Any idea why?

    Regards,

    Roy
  11. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 05 Oct 2011 Link to this post

    Hi Roy Halvorsen,

    We cannot say for certain what is the problem without looking into a runnable project. Verify that the database field is integer and if you have any data conversions in chart build methods - make sure they are correct.

    Kind regards,
    Steve
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  12. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 07 Oct 2011 Link to this post

    Hi again.

    I figured out what was the problem when sending a nullable int to my method.

    For some reason I have to convert the paramter to an Int like this:

    Convert.ToInt32(Report.ReportParameters[3].Value)

    A bit strange that a parameter declared as a nullable int is in fact not an int, but nevermind it works now.

    Roy
Back to Top
DevCraft banner