We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Expression Columns

Syncfusion 5.1
VS 2005

Can we create expression columns using conditional statements? For instance, can we use the expression
"IF [COL1]=1 THEN [COL2]*2 ELSE [COL2]*10"

Thanks

1 Reply

AD Administrator Syncfusion Team July 10, 2007 10:44 PM UTC

This is no built-in support for IF statements in an Expression column. But you can use the fact that logical expressions return 1 or 0 depending upon whether they are tru or not to write an expression that is thye equivalent of an IF statement using a linear combination of the true alternative and the false alternative weighted by the logical expression.

"([Col1] = 1) * ([Col2] * 2) + (1 - ([Col1] = 1)) * ([Col2] * 10)"


Another way is to use an unbound column instead of an expression column. In your QueryValue code that defines the value for the unbound column, you can write code to compute any value you want from the e.Record that is passed in.

Loader.
Live Chat Icon For mobile
Up arrow icon