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.
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...).
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 ?
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
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.