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

returning a field value in a IIF expression statement

2 Answers 383 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 2
Joe asked on 10 Aug 2016, 01:40 PM
Hello;
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,
Joe

2 Answers, 1 is accepted

Sort by
0
Accepted
Lance | Manager Technical Support
Telerik team
answered on 10 Aug 2016, 09:52 PM
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:





Regards,
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.
0
Joe
Top achievements
Rank 2
answered on 10 Aug 2016, 10:01 PM

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 --

 

Joe

Tags
GridView
Asked by
Joe
Top achievements
Rank 2
Answers by
Lance | Manager Technical Support
Telerik team
Joe
Top achievements
Rank 2
Share this question
or