that should be the one. Are you using visual studio and are you using IIS? If so you should be able to debug and see what value you are getting returned. I think of the top of my head its @Model.GetProperty("dropdownList").Value.ToString(). It might be the object you need which would be @Model.GetProperty("dropdownList").Value. Charlie :). Please could you make this solved if this works :). Thanks. Charlie :)
Hi, glad you got it done :). Can you maked this a solved :). I see what you have done with XPathNodeIterator calling it iterate. I dont know why but feels a bit obsure.
I wonder if anyone is still paying attention to this thread...
What I am trying to do is this. I have a checkbox data type that is a list of job categories (jobsCategory).
The parent node (Find-A-Job) will have children for each job, and one of the fields on the doctype is of course the category.
On the display page, I would like to iterate through all the categories, then under each one, show child nodes that have that value checked (if any). Something like this:
Construction
Job 1
Job 2
Operations
No Jobs found
Service
Job 1
Job 2
Just in case anyone can help, and to avoid confusion, here are some ids:
Parent Node (Find-A-Job): 1120
datatypeId: 1127
I know there has to be a way to do this, but I am not a programmer and am having a hard time trying to figure it out. Any help would be most appreciated.
getting values of checkbox data type
Hi
is there a way to get the value from a checkbox data type using razor? I mean the values and not the text of course.
Thanks
You can do
int preValue;
Int32.TryParse(your property, out preValue); //preValue as numeric value
string preValueAsString = umbraco.library.GetPreValueAsString(preValue);
Charlie :)
Great thanks is the syntax like this? instead of "your property"
that should be the one. Are you using visual studio and are you using IIS? If so you should be able to debug and see what value you are getting returned. I think of the top of my head its @Model.GetProperty("dropdownList").Value.ToString(). It might be the object you need which would be @Model.GetProperty("dropdownList").Value. Charlie :). Please could you make this solved if this works :). Thanks. Charlie :)
Thanks :)
and another question please what if I want to get all the pre-values of this data type, like in my sceenshot getting all the numbers from 6 to 9 ?
Sorry but your answer didn't work for me, this code does:
It will do, all your code is diffrent is getting the xml version rather than a strongly typed access.
ummm if you want to iterate through the values then i think you are going to need to parse the xml. the easy way would be something like:
XPathNodeIterator xpathIterator = umbraco.library.GetPreValues(preValue);
string xmlStr = "";
foreach (XPathNavigator n in xpathIterator)
{
xmlStr = n.OuterXml;
}
var x = new XmlDocument();
x.LoadXml(xmlStr);
XmlNodeList nl = x.SelectNodes("//preValues/preValue");
foreach (XmlNode xn in nl)
{
var li = new ListItem(xn.InnerText, xn.Attributes["id"].Value);
}
Man you're great
Thanks a lot for your help, this is my code I used the Current property in order to loose the first foreach loop
Hi, glad you got it done :). Can you maked this a solved :). I see what you have done with XPathNodeIterator calling it iterate. I dont know why but feels a bit obsure.
You're right, that a pretty poor naming convantion, but for this sample that'll do the trick :)
Thanks
How do I get the actual text string?
I wonder if anyone is still paying attention to this thread...
What I am trying to do is this. I have a checkbox data type that is a list of job categories (jobsCategory).
The parent node (Find-A-Job) will have children for each job, and one of the fields on the doctype is of course the category.
On the display page, I would like to iterate through all the categories, then under each one, show child nodes that have that value checked (if any). Something like this:
Construction
Job 1
Job 2
Operations
No Jobs found
Service
Job 1
Job 2
Just in case anyone can help, and to avoid confusion, here are some ids:
Parent Node (Find-A-Job): 1120
datatypeId: 1127
I know there has to be a way to do this, but I am not a programmer and am having a hard time trying to figure it out. Any help would be most appreciated.
If you want the values you need something like this, when you use checkboxes you get comma separated values.
is working on a reply...