You need to sign in to do that
Don't have an account?
Ravindra reddy M
How to store query result values in picklist
Hi All,
I query Account records first, then i need to store these values in pick list,
public with sharing class ProjectNameListed {
public string projectName{get;set;}
public List<Account> ProjectName(){
list<selectOption> projectDetails=new list<selectOption>();
List<Account> pro=[select id,name from Account];
return pro ;
}
}
vf page:
<apex:page controller="ProjectNameListed">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputLabel value="Project Name :"/>
<apex:SelectList size="1"/>
<apex:selectOptions value="{!pro}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
please let me know the solution
Thanks & Regards
Raveendra
I query Account records first, then i need to store these values in pick list,
public with sharing class ProjectNameListed {
public string projectName{get;set;}
public List<Account> ProjectName(){
list<selectOption> projectDetails=new list<selectOption>();
List<Account> pro=[select id,name from Account];
return pro ;
}
}
vf page:
<apex:page controller="ProjectNameListed">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputLabel value="Project Name :"/>
<apex:SelectList size="1"/>
<apex:selectOptions value="{!pro}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
please let me know the solution
Thanks & Regards
Raveendra
I think there are couple of errors in your code. Can you please try the below code -
Apex Controller
'ProjectNameListed' class has a method 'getProjectNames' which queries for all the available Accounts, iterates them to create options and adds to a get set variable of type 'List<SelectOption>'. The method 'getProjectNames' is then invoked via the constructor. It is very important to note that the code written in the constructor is the first thing that runs when a page loads.
Note that the <apex:selectList> is not a self closing tag and the <apex:selectOptions> tag is the child of <apex:selectList> tag.Visualforce
Now its working fine, I am new to salesforce please let me know the best sites to practice coding.
Thanks & Regards
Raveendra