You need to sign in to do that
Don't have an account?
Jeffrey Zhang
Multiselect selectlist with preset selected values.
We have a visualforce 'edit' page for a custom object. The variable is stored in a String (eg: " a;b;c"). I want to be able to pull the saved values and preselect them on a multi selectList so users don't have to reselect the old values when editing.
value = [select ....];
<apex:selectList value="{!value}" size="3" multiselect="true" label="blah" id="blah" >
<apex:selectOptions value="{!options}" />
</apex:selectList>
I've tried string format and String[] list format for 'value' and neither gets me any default selected values for this select list.
value = [select ....];
<apex:selectList value="{!value}" size="3" multiselect="true" label="blah" id="blah" >
<apex:selectOptions value="{!options}" />
</apex:selectList>
I've tried string format and String[] list format for 'value' and neither gets me any default selected values for this select list.
If you want to prefill a multi-select, you need use String[] list. Please, look at the code below:
Thanks,
Alex
All Answers
If you want to prefill a multi-select, you need use String[] list. Please, look at the code below:
Thanks,
Alex