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

how to display data in table after selecting a picklist value?

i need to get the data from the selected picklist..

the picklist is to have 5 records, if i selected 1 record from the piclist in the visual force page the cases object data is to mbe shown which is assigned to that contact.

can anyone help me with the code?
Best Answer chosen by Chinnoy
Veenesh VikramVeenesh Vikram
Something like this will help you:
<apex:page standardController="Contact" extensions="test_ctrl">
<apex:form >
  <apex:pageBlock >
      <apex:pageBlockSection >
          <apex:selectList value="{!selectedCon}" size="1">
              <apex:selectOptions value="{!Options}"></apex:selectOptions>
       <apex:commandButton value="Show Cases" action="{!showCases}"/>
       <apex:pageBlockTable value="{!caseList}" var="case">
           <apex:column headerValue="Case Number" value="{!case.CaseNumber}"/>
public class test_ctrl {
    Public Id selectedCon{get;set;}
    Public List<Case> caseList{get;set;}
    public List<SelectOption> getOptions(){
        List<SelectOption> tempList = new List<SelectOption>();
        for(Contact con : [SELECT Id, Name FROM Contact LIMIT 5]){
            tempList.add(new SelectOption(con.Id,con.Name));
        return tempList;
    public test_ctrl(ApexPages.StandardController controller) {
        caseList = new List<Case>();
    Public Void showCases(){
        caseList = [Select Id, CaseNumber FROM Case WHERE ContactId =:selectedCon];

Kindly mark as solved if this helps you!

Best Regards