Cannot perform '=' operation on System.Int32 and System.String

2 posts, 0 answers
  1. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 10 Oct 2008 Link to this post


    I was going through the SubReport video in Telerik trainer, except when assigning the filter I get the exact error described in the notes of the Filter wizard:

    Cannot perform '=' operation on System.Int32 and System.String

    Now, I'm following the exact instructions in the video, both fields from the database are indeed integers and even in checking the datasources I can see that my postID fields are both being read as integers.  I've tried every possible combination of different ='s and no ='s for the Filter property, but the only time I can get it to not throw the error is if I put an exact value in for the parameter, so instead of putting =Paramater.postID I just put in 30 (a known value in the postID's).  Any ideas as to why this error is being thrown?

    I know it says right there that this will be thrown in preview mode, but when put into production the error persists.  No clue how to avoid this as it is breaking the exact project that is in the trainer.  Any ideas would be welcome. :)

    Also, one issue I do notice is when I go into the Filter wizard, instead of the items I can pick they are all displayed as =Field.accID, =Field.postID, instead of just Field.accID, Field.postID.  Could this have anything to do with it?
  2. Steve
    Steve avatar
    10941 posts

    Posted 14 Oct 2008 Link to this post

    Hi Serrin,

    What version of the Telerik Reporting product do you use? Note that there was a similar bug in v.Q1 which has already been addressed.
    The equals sign (=)  in front of the filtering expression is so that the value is interpreted as an expression, otherwise it is considered as string value, and it might be the reason for the error you receive.

    Make sure your filter looks like this:
    Expression: =Field.YourField
    Operator: =
    Value: =Parameters.

    And when you pass a value to the parameter, in the report parameters dialog, you can use expression: =1234 .
    It will be evaluated to number 1234.
    And programmatically you can pass directly a number like this:

    this.ReportParameters["Id"].Value = 1234;

    Another thing not clear is, if are you passing some value to the defined parameter, because if you are not - this is the reason for the message you receive. When you do not set an initial value or do not pass such value before the report rendering, the value of the parameter is evaluated to an empty string.

    There are two ways to pass values to the parameters. The first one is to take advantage of the automatically generated UI, and let the end users to populate the parameters. The other is to set the value of the parameter programmatically using the ReportParameters collection of the report. More information how to setup and use the parameters you can find in the help article Report Parameters.

    I hope this information helps.

    Sincerely yours,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top