+ Start a Discussion

How to pass visualforce page record ID to controller

Hello Friends,

I have a requirement to get child records and display in VF page and update all records when they click save button, could you please send me the link or sample code if there is one?

VF page
checkbox   Field1   Field2   Field3 Field4
  -                      -       -           -          -
  -                      -        -          -          -
                 Save Button

If they click save button all selected checkbox records should be updated via Apex controller or Javascript function.

I am able to get the records to VF page but I couldnt get the selected record ID and pass it to controller

Any help on this really appreciate.

NagendraNagendra (Salesforce Developers) 

Sorry for this issue you are facing.

May I suggest you please refer to below link from the stack exchange community with a similar discussion which might help you further. Please let us know if this helps.

Kindly mark this as solved if the reply was helpful.

Ajay K DubediAjay K Dubedi

Please have a look to below code:

Apex Controller:-
public class Teamlist {
    public ApexPages.StandardSetController setTeam {
        get {
            if(setTeam == null) {
                setTeam = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [select id, name from Team__c]));
            return setTeam;
     public List<Team__c> getTeams() {
         return (List<Team__c>) setTeam.getRecords();
    public PageReference Go() {
      Id id = System.currentPageReference().getParameters().get('id');
      PageReference nextpage = new PageReference('/apex/CustomTeam?id='+id);
                return nextpage;

VisualForce Page:-
<apex:page controller="Teamlist" showHeader="false" title="false"> 
  <apex:form >
   <apex:tabPanel switchType="client" selectedTab="TabDetails" tabClass="activetab" inactiveTabClass="inactivetab">
        <apex:tab label="TEAM">
            <apex:pageBlock title="TEAMLIST">
                <apex:pageBlockTable value="{!teams}" var="t">
                    <apex:column headerValue="TEAM NAME">
                       <apex:outputPanel >
                            <apex:commandLink action="{!Go}">
                               {!t.name}<apex:param name="id" value="{!t.id}"/>
Here is a visualforce page containing a list of teams. What we want is after clicking a particular team name, it will go to a page where the details are displayed of that corresponding team. Here we are retrieving the team id using <apex:param name="id" value="{!t.id}"/> within commandLink where we defined the action.
Then we can observe that we defined that function in the apex controller for getting that id by System.currentPageReference().getParameters().get('id'); After that it is referenced in a different page with that id.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Ajay Dubedi