Using Umbraco 7.7 here and having an issue getting the selected values from a checkbox list.
I created the new data type with the Checkbox List property editor and loaded a few values. I added the custom datatype to my document type, checked a couple options and published it.
In my code-behind, I'm iterating through a bunch of child nodes and creating a simple list of the nodes attributes one of which is the selected options for the checkbox data type. (e.g. - going through a list of case studies and for each case study, show the categories that the study applies to.
The models were already enabled by default in 7.7.7 but for some reason it didn't see the structure of the field with Content.GetPropertyValue, but it didn't help me find the one forum note with the answer.
As you mentioned, it was already an IEnumberable which did confuse me as to why I couldn't iterate it the way I had in the past. This was the solution.
@foreach(var s in cs.GetPropertyValue<IEnumerable<string>>("studyProducts2")) {
<div>S: @s</div>
}
Getting Checkbox List Values
Hello All,
Using Umbraco 7.7 here and having an issue getting the selected values from a checkbox list.
I created the new data type with the Checkbox List property editor and loaded a few values. I added the custom datatype to my document type, checked a couple options and published it.
In my code-behind, I'm iterating through a bunch of child nodes and creating a simple list of the nodes attributes one of which is the selected options for the checkbox data type. (e.g. - going through a list of case studies and for each case study, show the categories that the study applies to.
I've tried this documentation with no success: https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/checkbox-list
....which gives the error "object does not contain a definition for 'Split'"
I've also tried this solution which gives the same error: https://our.umbraco.org/forum/using-umbraco-and-getting-started/86221-handling-checkbox-list-in-76-with-new-property-value-converters
I've done this in earlier versions of Umbraco and am just not sure what I'm missing.
Thank you in advance...
Hi Rick,
Are you using Content Models by any chance?
If so then the
studyProducts2
is already anIEnumerable<string>
Cheers
Matt
It looks like you are using dynamic the more I look at it.
You may want to look into the Models builder as Dynamics have a performance hit https://our.umbraco.org/documentation/Reference/Common-Pitfalls/#dynamics
@Matthew,
The models were already enabled by default in 7.7.7 but for some reason it didn't see the structure of the field with Content.GetPropertyValue, but it didn't help me find the one forum note with the answer.
As you mentioned, it was already an IEnumberable which did confuse me as to why I couldn't iterate it the way I had in the past. This was the solution.
Thanks for the insight!
is working on a reply...