returning a field value in a IIF expression statement

3 posts, 1 answers
  1. Joe
    Joe avatar
    52 posts
    Member since:
    Feb 2012

    Posted 10 Aug 2016 Link to this post

    I am using Telerik Winforms Gridview and the Column expression.

    I am trying to return data from a field (column) in a gridview using a IIF statement.
    The below works:
    IIF(customer_name='Bills Hairy Mess','win','lose')

    The below crashes the form:
    IIF(customer_name='Bills Hairy Mess',cust_ref_1_BOL,'lose')
    I also tried
    IIF(customer_name='Bills Hairy Mess',[cust_ref_1_BOL],'lose')

    cust_ref_1_BOL is a valid field name and is pickable from within the expression editor under 'fields'

    Is the above possible?

    Thank you,
  2. Answer
    Lance | Manager Technical Support
    Lance | Manager Technical Support avatar
    1168 posts

    Posted 10 Aug 2016 Link to this post

    Hello Joe,

    I'm responding here to close this forum thread as this is a duplicate of a support ticket for the same issue.

    For folks visiting the forums looking for a similar answer,you can indeed use a field name with an IIF expression. You just have to make sure there are no quotes around the field name.

    For example, I created a "Can Call" calculated column using the following IIF expression on a Northwind Customers table's Country and Phone fields

    IIF(Country = 'USA' , Phone  , 'no calls' ).

    That expression will yield the following result:

    Lance | Tech Support Engineer, Sr.
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. Joe
    Joe avatar
    52 posts
    Member since:
    Feb 2012

    Posted 10 Aug 2016 in reply to Lance | Manager Technical Support Link to this post

    Indeed you can.

    You do need to make sure that the field is in the columns list for the grid, which is what I was doing wrong.

    It can be not visible, but needs to be there (obviously).

    I had a need to exclude some columns from a export but still use them on the screen for calculations, this works fine by setting their visibility to false right before exporting.

    Thanks Lance --



Back to Top