+ Start a Discussion

pageblocktable with rows and columns and radio buttons as input values ?

HI I would like to know How to develop pageblocktable with first column as list of record names from the Master object and other 3 columns as input radio button and it should select only one radio button per record , I have to capture the result and save the column header value in the field with the record Name in another field in the child object.
Ispita Saha 20Ispita Saha 20
Can you attach a screenshot for clarity or just Type the output you want!
Your page would look something like this
<apex:pageBlockTable value="{!SurveyQuestions}" var="sq">
        <apex:column value="{!sq.questions}"/>
        <apex:column headerValue="Question options 1">
            <apex:selectRadio value="{!sq.answer1}">
              <apex:selectOptions value="{!items}"/>
		<apex:column headerValue="Question options 2">
            <apex:selectRadio value="{!sq.answer2}">
              <apex:selectOptions value="{!items}"/>
		<apex:column headerValue="Question options 3">
            <apex:selectRadio value="{!sq.answer3}">
              <apex:selectOptions value="{!items}"/>

	public List<SelectOption> getItems() {
		List<SelectOption> options = new List<SelectOption>(); 
		options.add(new SelectOption('1','1')); 
		options.add(new SelectOption('2','2')); 
		options.add(new SelectOption('3','3')); 
		return options; 

	public List<SurveyQuestionsWrapper> SurveyQuestions = new List<SurveyQuestionsWrapper>();
	public class SurveyQuestionsWrapper{
		public String question {get; set;}
		public Boolean answer1 {get; set;}
		public Boolean answer2 {get; set;}
		public Boolean answer3 {get; set;}
		public SurveyQuestionsWrapper(String question, Boolean answer1, Boolean answer2, Boolean answer3){
			this.question = question;
			this.answer1 = answer1;
			this.answer2 = answer2;
			this.answer3 = answer3;			
Above is psuedo code.. you need to develop your functionality around it
Hi VineetKumar,

Thanks for the reply i modified the code according to the exampl you mentioned. But when the page is loading value is getting selected for all the records loaded in the pageblock table . I am not able to get the selected value records in the controller with the value, Please help me to capture the list of selected records and get the value of the Proficiency.

<apex:page sidebar="false" controller="RadioinputController">
<apex:form >
<apex:pageBlock id="block3">
<apex:pageBlockTable value="{!skills}" var="sq">
<apex:column value="{!sq.Skill.Name}"/>
<apex:column headerValue="Proficiency">
<apex:selectRadio value="{!sq.answer1}">
<apex:selectOptions value="{!items}"/> </apex:selectRadio> </apex:column>
<apex:pageBlockButtons location="Bottom">
<apex:commandButton action="{!save}" value="save"/>
</apex:pageBlock> </apex:form> </apex:page>

Public Class RadioinputController
 public List<SkillsWrapper> skills {get;set;}
 public List<Skill__c> selectedskillrecord {get;set;}
    public RadioinputController()
      skills  = new List<SkillsWrapper>();
      for(Skill__c s : [select Name From Skill__c ] )
              skills.add(new SkillsWrapper(s));

    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('Basic Knowledge','Basic Knowledge'));
        options.add(new SelectOption('Intermediate','Intermediate'));
        options.add(new SelectOption('Advanced','Advanced'));
        return options;
    public class SkillsWrapper{
        public Skill__c skill {get; set;}
        public Boolean answer1 {get; set;}
        public SkillsWrapper(Skill__c s){
            Skill = s;
            answer1 = false;
    public void selectedrecords() {
        selectedskillrecord = new List<Skill__c>();
        for(SkillsWrapper wrapobj: skills){
    public pagereference save()
        system.debug('Selected Records:' +selectedskillrecord); 
        return Null;

Screenshot Output
For <apex:selectRadio> one value is selected by default, as atleast one must be selected.
For getting the value in controller, you need to do something like this:
public pagereference save(){
    for(SkillsWrapper swObject :  skills){
    system.debug('Selected Records:' +selectedskillrecord); 
    return Null;