function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
UmmiUmmi 

How to display Programs in Radio button?

In my Visualforce Page I need to display List of programs in a redio button with remaining fields.

Ex:   PROGRAM NAME                START DATE                 END DATE
  • Java                                    2/1/2017                        5/6/2017
  • C                                        5/2/2017                         7/7/2017
  • SALESFORCE                   8/3/2017                        11/11/2017I
I want to select only one program at a time  then I have button "save&next" .if i click that one i need to redirect to another page.
NagendraNagendra (Salesforce Developers) 
Hi,

May I request you please confirm the program values Java, Salesforce, C are they picklist values?

If so, Please check with sample code below and tweak it as per your requirement to display them as radio buttons on the visual force page.
Note that type__c is my picklist field.
 
Use following methos to get options for radio button on page
controller code:
 
public List<SelectOption> getTypes(){
            Schema.sObjectType sobject_type = customObject__c.getSObjectType();

            Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();

            Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
          
            List<Schema.PicklistEntry> pick_list_values = field_map.get('type__c').getDescribe().getPickListValues();

            List<selectOption> options = new List<selectOption>();

           for (Schema.PicklistEntry a : pick_list_values) {
                      options.add(new selectOption(a.getLabel(), a.getValue()));
          }
      return options;
 
to use this on page:
 
<apex:selectRadio value="{!customObject__c.Type__c}">
                    <apex:selectoptions value="{!types}"></apex:selectoptions>
 </apex:selectRadio>
Hope this helps.

Kindly mark this as solved if the information was helpful.

Thanks,
Nagendra
 
UmmiUmmi
No nagendra those are (Program NAme) Program__c object records.
NagendraNagendra (Salesforce Developers) 
Hi,

If you want to display the object records as radio button values in the visual force page please check with below link which might help. Please let us know if this helps.

Thanks,
Nagendra
 
UmmiUmmi
Vsualforce page code 

<apex:page controller="radiobutton" >
    <apex:form >

<apex:selectRadio >
  <apex:selectOptions value="{!items}" /><br/>
</apex:selectRadio>


    </apex:form>
</apex:page>


!!!!!!-------------Controller---------------------!!!!!!!!!!!!
public class radiobutton{
list<Account> myAccountsList = new List<Account>();

public radiobutton(){

myAccountsList = [ select id,name from account];
}
public List<SelectOption> getItems() {
  List<SelectOption> options = new List<SelectOption>(); 
  for (Account a : myAccountsList) {
    options.add(new SelectOption(a.Id, a.Name));
  }

  return options; 
}
}

Now i need to display more columns with Account means Phone number ,website,Type industry,etc how to add column? nagendra