You need to sign in to do that
Don't have an account?
su t
Displaying Picklist value dynamically
Hi,
So I'm creating a VF page. There is a coustom object called XYZ. Its has a picklist Field abc. I want to display abc as picklist value on my page. What will the code be in the class. Please help.
So I'm creating a VF page. There is a coustom object called XYZ. Its has a picklist Field abc. I want to display abc as picklist value on my page. What will the code be in the class. Please help.
your code will be in the class:
public class mytest{
public xyz__c xObj{get;set;}
public mytest(){
xObj = new xyz__c();
}
}
VF Page will be::
<apex:page controller="mytest">
<apex:form>
<apex:inputField value="{!xObj.abc__c}"/>
</apex:form>
</apex:page>
:::======================================================================:::
Qusetion Solved ? then mark as best answer to make helpful to others .....
public with sharing class Picklistselect {
public string selected{get;set;}
public Picklistselect()
{
}
public List<SelectOption> getpicklst()
{
List<SelectOption> option=new List<SelectOption>();
List<Account> acclst=[Select Name,website from Account];
option.add(new SelectOption('-None-','-None-'));
for(Account ob:acclst)
{
option.add(new SelectOption(ob.id,ob.Name));
}
return option;
}
}
****************************
Vf page
<apex:page controller="Picklistselect">
<apex:form >
<apex:pageBlock title="Choose Account from picklist">
<apex:pageBlockSection >
<apex:selectList value="{!selected}" size="1" label="Account">
<apex:selectOptions value="{!picklst}">
</apex:selectOptions>
</apex:selectList>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>