I've faced a problem converting an Object into String in flex . my object is mydropdown selecteditem and I want to convert it to string and show it on a label tag . I've tried ".toString()" and "as String" and "String()" but none of them worked . anyone has any experience with it ? thanks
2 Answers
The selectedItem object has data and label properties, depending on the data that you're supplying you'd want something like this:
mydropdown.selectedItem.label
3 Comments
m0j1
didn't work . when I use mydropdown.selectedItem.label , it shows nothing .
jss
Well it depends on the data that you're providing, using data and label is just convention. Is there a labelField that is defined for your DropDownList? In my example it would be labelField = "label".
m0j1
thanks , that worked . my labelField="genre" and I used it like myDropDown.selectedItem.genre and it worked . thank you very much
If your "mydropdown selecteditem" is a class that you wrote yourself, you could create a toString() method in there and make it return something useful.
1 Comment
m0j1
no . by mydropdown I meant the id of my DropDownList and it's selecteditem property