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
Abhishek Sharma 527Abhishek Sharma 527 

checkbox with records in visualforce

Hello There, I have created visualforce page which returns account records, I need checkbox in the result page along with records, can anyone plz guide how i can achieve that.
User-added image

// my visualforce code

<apex:page controller="Demo2VF_Class">
<apex:form >
    <apex:pageBlock title="Account information">
        <apex:pageBlockTable value="{!acc}" var="item">
            <apex:column value="{!item.id}"/>
            <apex:column value="{!item.name}"/>
            <apex:column value="{!item.Type}"/>
            <apex:column value="{!item.rating}"/>
        
        </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>

//my class code
public class Demo2VF_Class {
    
    public List<Account> acc{get;set;}
    
    public Demo2VF_Class(){
        acc = [Select id, name, Type, Account.Rating from Account];
      
        
    }
}
Best Answer chosen by Abhishek Sharma 527
Abhishek Sharma 527Abhishek Sharma 527
this would require wrapper class and this link https://www.salesforcetutorial.com/wrapper-class-wrapper-class-example/ helped me achieving this.
thanks.

All Answers

VinayVinay (Salesforce Developers) 
Hi Abhishek,

Check below working examples that can help you.

https://www.salesforcetutorial.com/use-apexcheckbox-tag/
https://www.biswajeetsamal.com/blog/how-to-retain-and-display-the-checkbox-selection-in-visualforce-paging/

Please mark as Best Answer if above information was helpful.

Thanks,
Abhishek Sharma 527Abhishek Sharma 527
this would require wrapper class and this link https://www.salesforcetutorial.com/wrapper-class-wrapper-class-example/ helped me achieving this.
thanks.
This was selected as the best answer