Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 22, 2013 @ 16:25
    Fuji Kusaka
    0

    Filter using CheckBox list

    Can someone point out how do i get to make a filtering using a CheckBox List.

    To be more precise i have a docType with CheckBoxList where admin can choose 4 different status.

    Here my razor code lies within the template. 4 of them so as to pull the 4 different status. All the nodes that has this docType where its status varies are all under a particular folder.

    So far if only 1 checkBox is Checked it works fine, but the thing is a node can also have 2 different status. As soon as 2 of them are checked it doesnt show anything.

    Here is my code from one of the template

    List<DynamicNode> offre = @Model.AncestorOrSelf(2).Descendants("sft").Items;    
               
    foreach(var s in offers.Where(x=>x.GetProperty("umbracoNaviHide").Value != "1" && x.GetProperty("htOffer").Value.ToString() != String.Empty && x.GetProperty("htOffer").Value.ToString() == "VPV").OrderByDescending(y=>y.CreateDate)){                   
    @s.Name <br/>
      }

    Here htOffer is the alias for the CheckBox List   

    Any help on this ?

  • Brendan Rice 538 posts 1099 karma points
    Sep 22, 2013 @ 16:53
    Brendan Rice
    0

    Hi Fuji,

    Can you print out the value of the check box list when there are multiple checkboxes selected?

    I assume the values are stored in CSV format. If they are just split the string on the comma which should output a string array, then use that in your query (WHERE IN...).

    Hope this helps.

    See this for an example:

    http://stackoverflow.com/questions/13381930/linq-query-a-string-array-in-c-sharp-if-contains-either-of-two-values

Please Sign in or register to post replies

Write your reply to:

Draft