• srinivas194861.3881088511650579E12
  • NEWBIE
  • 10 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
my vfpage:
<apex:page controller="picklistclass">
    <apex:form >
        <apex:pageblock >
            <apex:commandButton value="Show" action="{!show}"/>
            <apex:pageblocksection >
                <apex:selectList value="{!selectedAccId}" multiselect="false" size="1">
                    <apex:selectOptions value="{!Accountnames}"></apex:selectOptions>
                </apex:selectList>
<apex:outputField value="{!acc.Name}"/>
<apex:outputField value="{!acc.AccountNumber}"/>
</apex:pageBlockSection>       
</apex:pageblock>
    </apex:form>
</apex:page>

controller:
public with sharing class picklistclass
{
Account account;
    public Account acc { get; set; }
public list<contact> con{get;set;}
    public PageReference show()
    {
list<Account> acc = [Select Name, AccountNumber From Account Where Id =: selectedAccId ];
    return null;      
    }  
   
     public String selectedAccId{ get; set; }
    public List<selectOption> options=new List<selectOption>();
    List<Account> lstnames=new List<Account>();
   
    public List<selectOption> getAccountnames()
    {
        for(Account obj:[select Id,name from Account])
        {
            options.add(new selectOption(obj.name,obj.name));
        }
        return options;
    }
   
}
my vfpage:
<apex:page controller="picklistclass">
    <apex:form >
        <apex:pageblock >
            <apex:commandButton value="Show" action="{!show}"/>
            <apex:pageblocksection >
                <apex:selectList value="{!selectedAccId}" multiselect="false" size="1">
                    <apex:selectOptions value="{!Accountnames}"></apex:selectOptions>
                </apex:selectList>
<apex:outputField value="{!acc.Name}"/>
<apex:outputField value="{!acc.AccountNumber}"/>
</apex:pageBlockSection>       
</apex:pageblock>
    </apex:form>
</apex:page>

controller:
public with sharing class picklistclass
{
Account account;
    public Account acc { get; set; }
public list<contact> con{get;set;}
    public PageReference show()
    {
list<Account> acc = [Select Name, AccountNumber From Account Where Id =: selectedAccId ];
    return null;      
    }  
   
     public String selectedAccId{ get; set; }
    public List<selectOption> options=new List<selectOption>();
    List<Account> lstnames=new List<Account>();
   
    public List<selectOption> getAccountnames()
    {
        for(Account obj:[select Id,name from Account])
        {
            options.add(new selectOption(obj.name,obj.name));
        }
        return options;
    }
   
}