My goal is to get a list of all the values of a custom DataType.
Example:
DataType Name: ContentVisibility
Pre Values: Public Only, Private Only, Both Public and Private
How do I get access to it?
var dataTypeId = umbraco.cms.businesslogic.datatype.DataTypeDefinition.GetAll().First(d => d.Text == "ContentVisibility").Id;
This is obsolete and will be removed. What is the alternative to get the Id of a specific datatype?
I ultimately need to get all the possible values of a DataType and have to resort to using an enumerator to go through all the prevalues in the DataType.
public static Dictionary<int, object> GetPrevalues(int dataTypeId)
{
XPathNodeIterator preValueRootElementIterator = umbraco.library.GetPreValues(dataTypeId);
preValueRootElementIterator.MoveNext(); //move to first
XPathNodeIterator preValueIterator = preValueRootElementIterator.Current.SelectChildren("preValue", "");
var retVal = new Dictionary<int, object>();
while (preValueIterator.MoveNext())
{
retVal.Add(Convert.ToInt32(preValueIterator.Current.GetAttribute("id", "")), preValueIterator.Current.Value);
}
return retVal;
}
Get Id of Custom DataType
My goal is to get a list of all the values of a custom DataType.
How do I get access to it?
This is obsolete and will be removed. What is the alternative to get the Id of a specific datatype?
I ultimately need to get all the possible values of a DataType and have to resort to using an enumerator to go through all the prevalues in the DataType.
is working on a reply...