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
Ashok S 7Ashok S 7 

how can solve my requirment

Hai,
I have one requirment.
I created one vf page which display the records of the object along with checkbox.When i check the checkbox and click on the getrecord button it display corresponding record detail page.
here the code
vf page
-----------------------
<apex:page controller="EmployeeInformationcontroller" >
   <apex:form >
      <apex:pageBlock >
          <apex:pageBlockTable value="{!emplist}" var="e">
           <apex:column >
             <apex:inputCheckbox value="{!e.Selected__c}"/>
             </apex:column> 
          <apex:column value="{!e.First_Name__c}"/>
  <apex:column value="{!e.Middle_Name__c}"/>
  <apex:column value="{!e.Last_Name__c}"/>
  <apex:column value="{!e.Date_of_Birth__c}"/>
  <apex:column value="{!e.Father_Husband_Name__c}"/>
  <apex:column value="{!e.Marital_Status__c}"/>
  </apex:pageBlockTable>
     <apex:commandButton value="Get Record" action="{!Getrecord}"/>
      </apex:pageBlock>
   </apex:form>
</apex:page>
controller
---------------------------
public class EmployeeInformationcontroller 
{
    public list<Employee_Information__c> emplist{get;set;}
    public boolean selected{get;set;}
    public Id selectedid{get;set;}
    public EmployeeInformationcontroller()
    {
          //selectedid =ctrl.getRecord().Id; 
         selected = false;
         emplist = [select First_Name__c,Middle_Name__c,Last_Name__c,Date_of_Birth__c,Father_Husband_Name__c,Selected__c,Marital_Status__c from Employee_Information__c];
    
    }
    
    public PageReference Getrecord() 
    { 
        list<Employee_Information__c> emp1 = new list<Employee_Information__c>();
        Employee_Information__c ei = new Employee_Information__c();
        for(Employee_Information__c et:emplist)
        {
           
        }
        return null;
    }

}
please any one help me to slove this
 
Best Answer chosen by Ashok S 7
rushirushi
I hope this helps:
 
<apex:page controller="EmployeeInformationcontroller"  >
   <apex:form >
      <apex:pageBlock id="theBlock">
          <apex:pageBlockTable value="{!emplist}" var="e">
           <apex:column headerValue="checkBox">
             <apex:inputCheckbox value="{!e.Selected__c}"/>
             </apex:column> 
          <apex:column value="{!e.First_Name__c}"/>
  <apex:column value="{!e.Middle_Name__c}"/>
  <apex:column value="{!e.Last_Name__c}"/>
  <apex:column value="{!e.Date_of_Birth__c}"/>
  <apex:column value="{!e.Father_Husband_Name__c}"/>
  <apex:column value="{!e.Marital_Status__c}"/>
    </apex:pageBlockTable>
     <apex:commandButton value=" getRecord" action="{! getRecord}"/>       
      </apex:pageBlock>
   </apex:form>
</apex:page>

controller:

public class displayObject
{   
   public List<Employee_Information__c> emplist{get; set;}  
       
    public displayObject() {
       // get the all records   from the custom object          
        emplist = [select  ID,First_Name__c,Middle_Name__c,Last_Name__c,Date_of_Birth__c,Father_Husband_Name__c,Selected__c,Marital_Status__c from   Employee_Information__c];
    }
     public PageReference Getrecord() {
               for(Employee_Information__c et : emplist)
               {
                        if(et.Selected__c== true){
                                 Id obj = et.id;
                                 return new ApexPages.StandardController(  obj.getSObjectType().newSObject( obj)).view();
                }
       }
       return null;
  }    
}