Skip to main content

Posts

Showing posts with the label Comparing selectoptions element

Retrieving Value From SelctionOption List

Hi Guys  I am going to share about one issue which I have come across.  I was just  comparing some value of selectOption list by iterating that list. Here is the code:- list<SelectOption> listOfOptions; listOfOptions = new list<SelectOption>(); listOfOptions.add(new SelectOption('a','a') ); listOfOptions.add(new SelectOption('1','1') ); listOfOptions.add(new SelectOption('A','A') ); listOfOptions.add(new SelectOption('@','@') ); for(SelectOption option:listOfOptions){    if(option== 'A'){         System.debug('hi');    } } COMPILE ERROR: Comparison arguments must be compatible types: System.SelectOption, String To avoid this error we need to use getValue() met hod. list<SelectOption> listOfOptions; listOfOptions = new list<SelectOption>(); listOfOptions.add(new SelectOption('a','a') ); listOfOptions.add(new SelectOption('1','1') ...