Convert List<DataItem> to List<String>
I'm using the Feature Set to Data Item List to populate a Combox List in a Workflow, but I would also like to have that list in a String format (Array or Collection).
What is the easiest way to accomplish this? I know how to Cast an Object to an Array, but I'm not sure how to do it with Data Items:
CType(MyObject, IEnumerable(Of Object)).Cast(Of String)().ToArray()
0
-
Hi Francois,
The easiest way to convert a list of data items into a list of strings is this:
Assuming that you want to use the DataItem's value in the string, then you would follow the syntax above. Otherwise, if you want to use the DataItem's display value, then you use this notation:item.Display
You cannot just cast the list of dataitems into a list of string because dataitems come in a set or a pair of values (a display name and value) whereas the string is a single value. So you need to add the items from the dataitem list to the string in order to create a list.
I hope this helps.
Regards,
Carmen0 -
Super...thanks Carmen !!! 0 -
I'm interested in this solution but the image link is broken, can someone repost? 0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
3 kommentarer