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
Rajesh SFDCRajesh SFDC 

how to get all proflies and display in dropdown using visualforce and apex class

please send the sample code...

RoshRosh

Hi,

 You can use the following sample of code.

 

===VisualForce Page===

<apex:page controller="Test">
<apex:form >

<apex:selectList size="1" value="{!selectedProfile}" >
<apex:selectOptions value="{!ProfileOptions}" />
</apex:selectList>

</apex:form>
</apex:page>

 

====Controller====

public with sharing class Test {

public String selectedProfile {get; set;}

    public list<Selectoption> getProfileOptions() {
       list<Selectoption> profileOptions = new list<Selectoption>();
       list<Profile> profileList = [select Id, Name from Profile];
       for (Profile profile : profileList) {
          profileOptions.add(new SelectOption(profile.Name, profile.Name));
      }
      return profileOptions;
      }
}

 

 If it solves your problem  please mark it as a solution.