How do I get the selected prevalue from my custom datatype radio button list?
I have created a nice DocumentType with a nice generic property of a custom DataType. My DataType has the Property Editor set to Radio Button List and I have added five prevalues. Everything seems to be completely in order so far.
When I navigate to a content page of this document type I can indeed see that there is such a property of the right type.
When I try to get the value form this property I can't figure out how to get the right data? I would have expected to get the value I entered in the prevalue field and then selected in my content page. Instead I get the number '6'. I note that this number correlates exactly to [Umbraco].[db_owner].[cmsDataTypePreValues].[id] which is a bit odd? Why on earth would I get that value sent back to me?
Neither of these work. My scenario is more that I am in code and would prefer something like the latter option below.
var test1 = CurrentPage.localereplacement;
var test2 = Model.Content.Properties.First(p => p.PropertyTypeAlias == "localereplacement").GetValue<string>();
As stated both of these give back the number '6' and not my prevalue string.
How do I get the selected prevalue from my custom datatype radio button list?
I have created a nice DocumentType with a nice generic property of a custom DataType. My DataType has the Property Editor set to Radio Button List and I have added five prevalues. Everything seems to be completely in order so far.
When I navigate to a content page of this document type I can indeed see that there is such a property of the right type.
When I try to get the value form this property I can't figure out how to get the right data? I would have expected to get the value I entered in the prevalue field and then selected in my content page. Instead I get the number '6'. I note that this number correlates exactly to [Umbraco].[db_owner].[cmsDataTypePreValues].[id] which is a bit odd? Why on earth would I get that value sent back to me?
Neither of these work. My scenario is more that I am in code and would prefer something like the latter option below.
As stated both of these give back the number '6' and not my prevalue string.
Something like the following should work for you.
That's correct! Thank you that works. But it seems overly complicated to me.
is working on a reply...