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

How to add a checkbox in pageblocktable row?

I need to show all the custom object records in pageblocktable. Before populating all the records i need to add a picklist value, Checkbox in the first row and then populate all the records. How can i do that. Here is the screenshot and VF code and class.

User-added image

VF code:
<apex:page standardcontroller="Opportunity" extensions="oppgapstatus">
<apex:pageBlockSection id="Info">
<apex:pageBlockTable value="{!WrapperList}" var="wraprec">
<apex:column value="{!wraprec.accRec.Name__c}"/>
<apex:column value="{!wraprec.accRec.Satisfied__c}"/>  
<apex:column value="{!wraprec.accRec.Current_Status__c}"/>
<apex:column value="{!wraprec.accRec.LastModifiedDate}"/>
<apex:commandbutton value="Save" action="{!UpdateSelectedRecords}"/>
<apex:commandbutton value="Cancel"/>

Apex class:
Public class oppgapstatus{
 Public Opportunity optyList{get;set;}
 Public Opportunity_Status__c opst{get;set;}
  public PageReference openPresentationOptions() {
      return null;
 private ApexPages.StandardController controller;
 public oppgapstatus(ApexPages.StandardController controller) {
//Checkbox selectall        
Public List<wrapperclass> wrapList {get;set;}
Public boolean checked{get;set;}
Public string selectedField {get;set;}
Public string inputVal{get;set;}
  Public void selectallnone(){
      checked = true;
      checked = false;

  Public List<wrapperclass> getWrapperList(){
   wrapList = New List<wrapperclass>();
   for(Opportunity_Status__c acc:[select name,Satisfied__c,Current_Status__c,LastModifiedDate from Opportunity_Gaps__c where Opportunity_Detail__c =: optyList.Id]){
     wrapList.add(New wrapperclass(acc,false)); 
     wrapList.add(New wrapperclass(acc,true));   
   return wrapList; 
   Public class wrapperclass{
   Public Opportunity_Status__c accRec{get;set;}
   Public boolean checkFlag{get;set;}
   Public wrapperclass(Opportunity_Status__c acc,boolean flag){
    accRec = acc;
    checkFlag = flag;

Can anyone help me.? Thanks in advance
Amit Chaudhary 8Amit Chaudhary 8
Shrikant BagalShrikant Bagal
Please try following link:


if its resolved your issue,please mark as best answer so it will help to other who will serve same problem.
Suraj Tripathi 47Suraj Tripathi 47
Hi Raj88,

You can add checkbox in your page using below line of code.
<apex:inputCheckbox value="{!c.yourValue}" />

If you find your Solution then mark this as the best answer.

Thank you!

Suraj Tripathi