Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

How to get value from Umbraco.DropDown.Flexible #101

Open
croban opened this issue Sep 27, 2018 · 1 comment
Open

How to get value from Umbraco.DropDown.Flexible #101

croban opened this issue Sep 27, 2018 · 1 comment

Comments

@croban
Copy link

croban commented Sep 27, 2018

How can I get dropdown value from an Umbraco.DropDown.Flexible datatype?

GetValue() does not working
GetValue() return [ "123" ] <- the number is there just what is it inside json or array of string?

@deadlybyte
Copy link

Came across this exact issue today and here's a workaround.

@using Newtonsoft.Json.Linq; // Need to add namespace
...
var selectedOption = JArray.Parse(item.GetValue<string>("option"));
var optionAsIntArray = selectedOption.Values<int>(); // Cast to int array
var selectedValue = Umbraco.GetPreValueAsString(optionAsIntArray.FirstOrDefault());

Hopefully it'll help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants