I've created a datatype with a dropdown list as rendercontrol and added some prevalues to choose from.
But how do I get these prevalues in my usercontrol codebehind? I want to create a form where I can choose one of the prevalues from the dropdown list set in the datatype.
to retrieve a sorted list of prevalues for a specific dropdown. You'll have to reference the cms assembly. parameter datatypeId is of type int; to find out your id, hover over the datatype in the Developer section and have a look at bottom left
A datatype is more to be considered as a 'prototype' as it might serve as the basis of one or more data types. (For example, one may use the ultimate picker more than once - let's say as being a checkbox list iterating all child nodes of node X, or as a dropdownlist listing all child nodes of node Y)
In the above example, two datatypes would be created, both based on the same datatype 'prototype'. Both datatypes will have the same guid identifier, but have a different id (which is the id of the node). Getting prevalues is always based on the id of the datatype.
I agree that the 'ID' may be different, but the Guid will remain across multiple umbraco installations.
It's something you'll have to lookup either in code (if your datatype implements IDataType, it will implement a property 'Id' which returns the Guid), otherwise perform a db lookup.
For example, the 'label' datatype (which is available oob in umbraco) has a node id = -92 (table umbracoNode). Find that id in table cmsDatatype and find the corresponding objectId. Column objectid holds the guid of the datatype.
Get custom dropdown datatype values
I've created a datatype with a dropdown list as rendercontrol and added some prevalues to choose from.
But how do I get these prevalues in my usercontrol codebehind? I want to create a form where I can choose one of the prevalues from the dropdown list set in the datatype.
Hi,
Can use:
to retrieve a sorted list of prevalues for a specific dropdown. You'll have to reference the cms assembly. parameter datatypeId is of type int; to find out your id, hover over the datatype in the Developer section and have a look at bottom left
Hope this helps.
Regards,
/Dirk
Perfect! To be precise, it's in the
Namespace. Thank you.
I am sorry for my bad english, but must too learn it better. I come from Germany.
thanks for this helps, but i search the method to request the DataTypeID by the name.
greets Stipo
Hi stipo,
As far as I'm aware, you can only get the datatype definition either by id or by its unique guid
. I'd recommend against querying the db directly, but it's also possible that way. Lastly, you could also consider getting all datatypes using
and as a datatype is just another 'cms node', you could iterate the list to find the one you need based on the
property
Hope this helps.
Regards,
/Dirk
Hi Dirk,
thanks for helps. I hope understand correctly your help, and i currently test it.
Else i must go the same way and querying the db directly.
But this feature is too needed anywhere, and developers can do this in the Sources.
I have come to this, after copying the WebSite over packages, that the DataTypeId ID never the same is.
Greets Stipo
Hi Stipo,
Have to add some extra info:
A datatype is more to be considered as a 'prototype' as it might serve as the basis of one or more data types. (For example, one may use the ultimate picker more than once - let's say as being a checkbox list iterating all child nodes of node X, or as a dropdownlist listing all child nodes of node Y)
In the above example, two datatypes would be created, both based on the same datatype 'prototype'. Both datatypes will have the same guid identifier, but have a different id (which is the id of the node). Getting prevalues is always based on the id of the datatype.
I agree that the 'ID' may be different, but the Guid will remain across multiple umbraco installations.
Cheers,
/Dirk
Hi Dirk,
thanks, you helping me very. I need the Guid in my methode.
I have the last question. Where can see what for Guid have my DataType?
Greets Stipo
It's something you'll have to lookup either in code (if your datatype implements IDataType, it will implement a property 'Id' which returns the Guid), otherwise perform a db lookup.
For example, the 'label' datatype (which is available oob in umbraco) has a node id = -92 (table umbracoNode). Find that id in table cmsDatatype and find the corresponding objectId. Column objectid holds the guid of the datatype.
Hope this helps.
Regards,
/Dirk
Thanks. I have enought information to developing my UserControl.
All others can self find, else then i question in a new topic with my problem.
Greets Stipo
is working on a reply...