Use Custom Settings in Apex Class on a Visualforce Page
public with sharing class CustomSettingsSampleController {
public String selectedCodes {get;set;}
public List<selectOption> Codes {
get {
List<selectOption> options = new List<selectOption>();
for (Country__c coun : Country__c.getAll().values())
options.add(new SelectOption(coun.Code__c,coun.Name+' - '+coun.Code__c));
return options;
}
set;
}
}
public String selectedCodes {get;set;}
public List<selectOption> Codes {
get {
List<selectOption> options = new List<selectOption>();
for (Country__c coun : Country__c.getAll().values())
options.add(new SelectOption(coun.Code__c,coun.Name+' - '+coun.Code__c));
return options;
}
set;
}
}
<apex:page controller="CustomSettingsSampleController">
<apex:sectionHeader title="Custom Settings" subtitle="Country Code List"/>
<apex:form >
<apex:pageBlock >
<apex:selectList value="{!selectedCodes}" size="1">
<apex:selectOptions value="{!Codes}"/>
</apex:selectList>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:sectionHeader title="Custom Settings" subtitle="Country Code List"/>
<apex:form >
<apex:pageBlock >
<apex:selectList value="{!selectedCodes}" size="1">
<apex:selectOptions value="{!Codes}"/>
</apex:selectList>
</apex:pageBlock>
</apex:form>
</apex:page>
Comments
Post a Comment