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
vamshi(Nani)vamshi(Nani) 

How to display a relted record of selected list

<apex:page controller="SelectList3">
<apex:form >
<apex:selectList value="{!slv}" size="1">
<apex:actionSupport event="onchange" reRender="out" />
<apex:selectOptions value="{!value}">
</apex:selectOptions>
</apex:selectList>
</apex:form>
<apex:outputPanel id="out">
<apex:outputText value="{!slv}">

</apex:outputText>

</apex:outputPanel>

</apex:page>

--------------------------controller------------------------
public with sharing class SelectList3
{
public list<selectoption> getValue()
{
list<SelectOption> ls= new list<SelectOption>();
for(Contact acc:[select id, name from Contact])
{
ls.add(new SelectOption(acc.id,acc.name));
}
return ls;
}

public String slv { get; set; }

}

 

 

 

 

 

 

 

 

 

 

 

 

 

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Now my question is how to pass the select value to a method..and fetch the value of record details with that id...Find detailed explination below..

In above code with the slv will return "id" of the selected value... Now using this Id I want to get related values of Account[ name etc..] please help me

 

vamshi(Nani)vamshi(Nani)

Hmmm...lots of trials I got the solution, It is simple.. but It was taken so much time.. hence..My code is like below.. suggest if there is need of improvements.. Thankyou....please find the code below.

<apex:page controller="SelectList3" tabStyle="Account">
    <apex:form >
    <apex:pageBlock >
      <apex:pageBlockSection title="Contact List" collapsible="false">
        <apex:selectList value="{!slv}" size="1" label="Account List">
            <apex:actionSupport event="onchange" reRender="table" />
            <apex:selectOptions value="{!value}">                     
            </apex:selectOptions>               
        </apex:selectList>
       </apex:pageBlockSection>
     </apex:pageBlock>
    </apex:form>
    <apex:pageBlock title=" Value of contacts">
    <apex:pageBlockSection >
    <apex:outputPanel id="out">
       <apex:pageblockTable value="{!tabledata}" var="c" cellpadding="2px" id="table">
           <apex:column value="{!c.name}" headerValue="Account Name"/>
           
               
       </apex:pageblockTable>
       
    </apex:outputPanel>
    </apex:pageBlockSection>
  </apex:pageBlock>
</apex:page>

 

public with sharing class SelectList3 
{

    public list<Account> getTabledata()
     {           
          list<Account> con=[select name from Account where id=:slv];        
          return con;
     }


       public list<selectoption> getValue()
     {
        list<SelectOption> ls= new list<SelectOption>();
        for(Account acc:[select id, name from Account])
        {
            ls.add(new SelectOption(acc.id,acc.name));
        }
        return ls;
    }

    public string slv{get;set;}
    
   
    
}