I'm a relative newbie so please be gentle...

I've created a visualforce page using a custom controller. The VF page contains a number of fields and a drop down list (i.e. Industry) from which users can search for data. I would like the VF page to display 'All Industries' on page load. However, I can't get this to work.

My constructor snippet is as follows:

public MyController(){
    AccountList = new list<AccountSubClass>();
    AccountSelectedSet = new set<Id>();

    Industry = ApexPages.currentPage().getParameters().get('All Industries');


Grateful for any assistance. Happy to provide more details if it helps...

1 Answer 1


You have a couple of options here, you can either build your drop-down list in your Visualforce page or you can build it in apex. To do it in Visualforce, you just need VF markup that looks something like this:

<apex:selectlist value="{!selectedndustry}" size="1">
     <apex:selectOption itemValue="all" itemLabel="All Industries"/>

And the apex for that would look something like this:

 public string selectedIndustry { get; set; }

Alternatively, you can build your list of SelectOptions in apex and repeat over them on the page. The apex for that would look like this:

<apex:selectlist value="{!selectedIndustry}" size="1">
     <apex:selectOptions value="{!industries}" />

And the apex for that would look something like this:

public string selectedIndustry { get; set; }
public list<SelectOption> getIndustries (){
     list<SelectOption> options = new list<SelectOption>();
     options.add(new SelectOption('all','All Industries'));
     return options;
  • Thanks for your response greenstork. Perhaps I should have been clearer in my earlier post as I already have that functionality built into my VF page. What I'd like is that when the page loads, it does so displaying all of the data in my Accounts object. The user can then use the search to refine the list. Hope that makes sense...
    – Robert
    Commented Oct 21, 2014 at 19:51
  • If you are displaying data about an existing acccount record, then you either need to query for the account or use a controller extension and get the record from the standard controller in your extension constructor.
    – greenstork
    Commented Oct 21, 2014 at 19:54
  • I'm using a custom controller which queries the object and retrieves the results; this works reasonably well. But I can't get the data to populate my pageBlockTable when the page loads, only through the search. Any suggestions??
    – Robert
    Commented Oct 21, 2014 at 20:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .