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
Heena.Heena. 

how to create a dropdown in this

<apex:page controller="wrapperClassController">
 <apex:form >
  <apex:pageBlock >
      
  <apex:pageBlockSection>
          
   </apex:pageBlockSection>
      
      
   <apex:pageBlockButtons >
     <apex:commandButton value="send survey" action="{!sendsurvey}" rerender="table"/>
   </apex:pageBlockButtons>
                <!-- In our table we are displaying the cContact records -->
         <apex:pageBlockTable value="{!contacts}" var="c" id="table">
            <apex:column >
              <!-- This is our selected Boolean property in our wrapper class -->
           <apex:inputCheckbox value="{!c.selected}"/>
           </apex:column>
             <!-- This is how we access the contact values within our cContact container/wrapper -->
           <apex:column value="{!c.con.Name}" />
           <apex:column value="{!c.con.Email}" />
           <apex:column value="{!c.con.Phone}" />
      </apex:pageBlockTable>
    </apex:pageBlock>
  </apex:form>

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

public class wrapperClassController {

    
        //Our collection of the class/wrapper objects cContact
        public List<cContact> contactList {get; set;}
    
        //This method uses a simple SOQL query to return a List of Contacts
        public List<cContact> getContacts() {
            if(contactList == null) {
                contactList = new List<cContact>();
                for(Contact c: [select Id, Name, Email, Phone from Contact limit 10]) {
                    // As each contact is processed we create a new cContact object and add it to the contactList
                    contactList.add(new cContact(c));
                }
            }
            return contactList;
        }
         
        public PageReference sendsurvey() {    
                    //We create a new list of Contacts that we be populated only with Contacts if they are selected
            List<Contact> selectedContacts = new List<Contact>();


            //We will cycle through our list of cContacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list

            for(cContact cCon: getContacts()) {

                if(cCon.selected == true) {
                    selectedContacts.add(cCon.con);
                }
            }
    
            // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
            System.debug('These are the selected Contacts...');
            for(Contact con: selectedContacts) {
                system.debug(con);
            }
            contactList=null; // we need this line if we performed a write operation  because getContacts gets a fresh list now
            return null;
        }
    
    
        // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
        public class cContact {
            public Contact con {get; set;}
            public Boolean selected {get; set;}
    
            //This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property. We also set the selected value to false
            public cContact(Contact c) {
                con = c;
                selected = false;
            }
        }
    }
Raj VakatiRaj Vakati
Make the changes as below
 
<apex:page controller="wrapperClassController">
    <apex:form >
        <apex:pageBlock >
            
            <apex:pageBlockSection >
                
            </apex:pageBlockSection>
            
            
            <apex:pageBlockButtons >
                <apex:commandButton value="send survey" action="{!sendsurvey}" rerender="table"/>
            </apex:pageBlockButtons>
            <apex:selectList value="{!contact}" multiselect="false">
                <apex:selectOptions value="{!items}"/>
            </apex:selectList><p/>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class wrapperClassController {
    
    
    //Our collection of the class/wrapper objects cContact
    public List<cContact> contactList {get; set;}
    
    //This method uses a simple SOQL query to return a List of Contacts
    public List<cContact> getContacts() {
        if(contactList == null) {
            contactList = new List<cContact>();
            for(Contact c: [select Id, Name, Email, Phone from Contact limit 10]) {
                // As each contact is processed we create a new cContact object and add it to the contactList
                contactList.add(new cContact(c));
            }
        }
        return contactList;
    }
    
    
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        
        if(contactList == null) {
            contactList = new List<cContact>();
            for(Contact c: [select Id, Name, Email, Phone from Contact limit 10]) {
                // As each contact is processed we create a new cContact object and add it to the contactList
                //  contactList.add(new cContact(c));
                options.add(new SelectOption(c.Name,c.Name));
                
            }
        }
        
        return options;
    }
    
    String[] contact = new String[]{};
        
        public String[] getContact() {
            //If multiselect is false, countries must be of type String
            return contact;
        }
    
    public void setContact(String[] contact) {
        //If multiselect is false, countries must be of type String
        this.contact = contact;
    }
    
    public PageReference sendsurvey() {    
        //We create a new list of Contacts that we be populated only with Contacts if they are selected
        List<Contact> selectedContacts = new List<Contact>();
        
        
        //We will cycle through our list of cContacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list
        
        for(cContact cCon: getContacts()) {
            
            if(cCon.selected == true) {
                selectedContacts.add(cCon.con);
            }
        }
        
        // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
        System.debug('These are the selected Contacts...');
        for(Contact con: selectedContacts) {
            system.debug(con);
        }
        contactList=null; // we need this line if we performed a write operation  because getContacts gets a fresh list now
        return null;
    }
    
    
    // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
    public class cContact {
        public Contact con {get; set;}
        public Boolean selected {get; set;}
        
        //This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property. We also set the selected value to false
        public cContact(Contact c) {
            con = c;
            selected = false;
        }
    }
}

 
Heena.Heena.
dear sir the prog which you have sent me it's showing list of contact in dropdown form. I don't want list of contact in dropdown form i want a dropdown option beside sendsurvey to custom survey which i have created. Contact list should be with checkbox form only which i have already done. Only the thing is i want a dropdown option beside sendsurvey button to select my custom survey. waiting for your reply. Thanks in advance, Heena.