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
adi salesforceadi salesforce 

How to display list of records using set

AshishkAshishk
<apex:page controller="repeatCon" id="thePage">

    <apex:repeat value="{!strings}" var="string" id="theRepeat">

        <apex:outputText value="{!string}" id="theValue"/><br/>

    </apex:repeat>

</apex:page>


/*** Controller: ***/

public class repeatCon {

    public set<string> getStrings() {
        return new set<String>{'ONE','TWO','THREE'};
    }

}

see above code, it will show records on VF page.

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_repeat.htm

Hope this works.
Thanks
Ajay K DubediAjay K Dubedi
Hi adi,
Please try this code:

Vf page:
<apex:page controller="setvfcontroller" >
 <apex:pageBlock>
  <apex:repeat value="{!myset}" var="s" id="theRepeat">

        <apex:outputText value="{!s}" id="theValue"/><br/>

    </apex:repeat>    
    
    
 </apex:pageBlock>
</apex:page>

Controller class:

public class setvfcontroller {
    public set<String> myset{get;set;}
    public setvfcontroller()
    {
        myset=new set<String>();
        myset.add('value1');
        myset.add('value2');
        myset.add('value3');
        myset.add('value4');
        myset.add('value5');
        system.debug('set'+myset);
    }
}
Hope this will help you.Mark it as best answer if you find it helpful.

Thanks.
Ajay Dubedi