How to get a value in multichoice field

Monjoie Dominique asked on March 26, 2015 12:21


I work with Kentico since a few months and I have a little problem to select a value among some others : I usually use something like <%# IfCompare(Eval("X"), true, "", GetImageByUrl("~/media/pictos/prod/prod_fl.gif")) %> with the value is True or 1 follwing the type used for the radio button in the field : Boolean or Text.

My aim is to display a different picture in regard of the value of 'X' which is stored as a multichoice value : 1,2,4 ....

To be short, I don't know what to write instead of 'True' or '1' in the case where I need to get a value among others. In a repeater, I use X LIKE '%1%' (I have less than 9 possible values) but in this case, I don't know how to specify that.

In advance, thanks. Sorry for my poor English,

Best regards

Correct Answer

Brenden Kehren answered on March 26, 2015 12:53

Your resulting WHERE statement would look something like the following:

WHERE (ColumnName LIKE '%|123|%' OR ColumnName = '123' OR ColumnName LIKE '%123|%' OR ColumnName LIKE '%|123%')

To make this happen in a transformation, it might get to be pretty ugly inline, so you might want to create a custom transformation method or just a method within the page load event in the transformation.

1 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.