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
sweety kuttisweety kutti 

How to pass the record id to controller on click of single radio button inside apex:repeat

Navin SoniNavin Soni
HI Sweety,
// Controller
public Class PassRecordId{
public String Id{get;set;}
public List<Account> listOfAccounts{get;set;}
public List<Account> listOfSelectAccount{get;set;}
    public PassRecordId(){
        ListOfAccounts =  [SELECT Id From Account LIMIT 10000] ;
    }
    public void AccountRecords(){
        listOfSelectAccount =  [SELECT Id From Account Where Id =: Id LIMIT 1] ;
        system.debug(listOfSelectAccount);
    }
}

// Page
<apex:page controller="PassRecordId" id="thePage">
    <apex:repeat value="{!listOfAccounts}" var="AccountId" id="theRepeat">
        <apex:selectRadio value="{!Id}">
            <apex:selectOptions value="{!AccountId.id}"/>
        </apex:selectRadio>
    </apex:repeat>
<apex:commandButton action="{!AccountRecords}" value="Get Account"/>
</apex:page>