How to get/set value of field with "Allow multiple choices" enabled via Kentico API?

Targutai Yesugei asked on August 4, 2017 05:58

In other words, i have List of strings and i need to set field values with all of them, or get List of strings from this field. I tried to pass value "va1\nval2\nval3" but it didn't work.

Sorry, question text was cut, hope fixed it

Correct Answer

Trevor Fayas answered on August 4, 2017 15:36

Targutai, if you are setting it to the TreeNode, you will need to JOIN the values. What the string delimeter is (semi colon (;), comma (,), or bar (|)) depends on either the selector you use or how you handle them.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on August 4, 2017 06:02

Use string.Split() and get your string into an array. Typically they are stored as pipe delimited values.

1 votesVote for this answer Mark as a Correct answer

Targutai Yesugei answered on August 4, 2017 11:04

I tried to pass string array to TreeNode.SetValue() but there was an exception : No mapping exists from object type System.String[] to a known managed provider native type.

0 votesVote for this answer Mark as a Correct answer

Targutai Yesugei answered on August 9, 2017 10:06

Thank you Trevor! I needed to split my values with "|" char.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.