Compare and display

Monjoie Dominique asked on June 21, 2018 17:05

Hi,

I created a multichoice field called 'Particularities' with 2 distinct kinds of values : a1 -> a10 and e1 -> e10. Following what is fullfilled, I'd like to display in the page 2 different titles : Attractions if there is at least one value with 'a...' and Equipment if there is at least one choosen value with 'e...'.

I try something with IfCompare (Eval(Paticularities) ... but Idon't know how to put all the informations between the commas. What I have to display is something like

    <asp:placeholder runat="server" visible=<%# CustomFunction.SelectionContains(Eval("Particularities"),"a1") %>>
        <img alt="" src='/Apaqw/media/pictos/aw/picto_meat_32.png' />
    </asp:placeholder>   
    <asp:placeholder runat="server" visible=<%# CustomFunction.SelectionContains(Eval("Particularities"),"a2")%>>
        <img alt="" src='/Apaqw/media/pictos/aw/picto_vol_32.png' /> 
    </asp:placeholder>    

and so on until e10. I try to add another <asp:placeholder> with value "a" but I think in this case, I'll have to write LIKE '%a%' but I don't know how to do ? Will it be possible to put a 'placeholder' WebPart, to put an 'If condition' inside and following the result, to display or not the pictos regarding the values of my Particularities field.

Maybe I'm not very explicite but my english is not very good.

Thanks for any help,

Correct Answer

Brenden Kehren answered on June 21, 2018 17:35

With the multiple choice fields you need to include all possible values. Meaning your LIKE statement needs to have:

FieldName LIKE '%|a1|%' OR FieldName LIKE 'a1|%' OR FieldName LIKE '%|a1'

You do this because with a multichoice field, you can have 1 or many items in the field.

For example, if the data in the field was:

a1|e1|d1

The LIKE evaluation of '%|a1|%' would not get the value. BUT the LIKE evaluation of 'a1|%' would.

Same would be true for looking for the value of d1. The LIKE evaluation of '%|d1' would be the only evaluation which would capture that value existed in the string.

0 votesVote for this answer Unmark Correct answer

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