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
Jagadeesh AdaveniJagadeesh Adaveni 

How to display Edit page Picklist value in Detail page?

Hi All,

I have two visualforce pages(Editpage one VF and Detail page one VF) for one object.
In Editpage VF i have created one Dynamic Picklist and after saving my page that Picklist is not available in Detail page of VF. Shall what changes i do in Detail Page.
Editmode VF page
-------------------------


             <apex:pageblockSectionItem >
               <apex:outputLabel >Payment Mode</apex:outputLabel>
               <apex:selectList value="{!svalue}" size="1">
               
               <apex:actionsupport event="onchange" action="{!picklistPB}" />
                   <apex:selectOptions Value="{!picklistFunction}"></apex:selectOptions> 
               </apex:selectList>
             </apex:pageblockSectionItem>

Controller
---------------

public List<selectOption> getpicklistFunction()
    {
    List<selectOption> studentName =new List<selectOption>();
        List<Student__c> studentList = new List<Student__c>();
        List<Student__c> stuList = [select id,name,Payment_mode__c,Location__c,Location__r.Payment_mode__c from Student__c where id =: ApexPages.currentPage().getParameters().get('id')];
        
        studentName.add(new selectOption('--None--','--None--'));
        for(Student__c st : stuList)
        {
            st.payment_mode__c = st.Location__r.Payment_Mode__c;
         
            if(st.Location__r.Payment_Mode__c=='ACH;Check;Credit Card')
            {
             studentName.add(new selectOption('Check','Check'));
             studentName.add(new selectOption('Credit Card','Credit Card'));
             studentName.add(new selectOption('ACH','ACH'));
             }
             
             else{
             
             if(st.Location__r.Payment_Mode__c=='Check;Credit Card'){
             studentName.add(new selectOption('Check','Check'));
             studentName.add(new selectOption('Credit Card','Credit Card'));}
             
             else
             {
             
             if(st.Location__r.Payment_Mode__c=='ACH;Credit Card'){
             studentName.add(new selectOption('ACH','ACH'));
             studentName.add(new selectOption('Credit Card','Credit Card'));}
             
             else
             {
             if(st.Location__r.Payment_Mode__c=='ACH;Check'){
             studentName.add(new selectOption('ACH','ACH'));
             studentName.add(new selectOption('Check','Check'));}
             else
             {
             if(st.Location__r.Payment_Mode__c=='ACH')
             studentName.add(new selectOption('ACH','ACH'));
             else
             {
             if(st.Location__r.Payment_Mode__c=='Check')
             studentName.add(new selectOption('Check','Check'));
             else
             {
             if(st.Location__r.Payment_Mode__c=='Credit Card')
             studentName.add(new selectOption('Credit Card','Credit Card'));             
             }
             }
             }
             }
             }
             }
             
            
        }
           
                    
        return studentName ;
    }
    
    public PageReference picklistPB()
    {
    
        
                if(svalue.contains('Credit Card'))
                studentAcceptsCC = true;
                else
                studentAcceptsCC = false;
                
                if(svalue.contains('ACH'))
                studentAcceptsACH = true;
                else
                studentAcceptsACH = false;
                
                if(svalue.contains('Check'))
                studentAcceptsCheck = true;
                else
                studentAcceptsCheck = false;
        
        return null;
    
    }

Thanks
Jagadeesh
KaranrajKaranraj
Jagadeesh - You have store the picklist value in the object else you can't display the value. Assign the 'sValue' to the field in which you are going to store the value.
Jagadeesh AdaveniJagadeesh Adaveni
Hi Kanakaraj

Could you please Elobarate i am not getting, It is urgent requirement.
KaranrajKaranraj
Are you using standard controller or cusotm controller? You have to store the value some where to display. In which field you are storing the value of picklist? Can you share the save method of your code? 
Jagadeesh AdaveniJagadeesh Adaveni
I am not storing those values anywhere else.Moreover am using Standard Controller
KaranrajKaranraj
You must store that value in the field of the object in order to disaply that while viewing the page. You have to override the save button of the standard controller and store the picklist value in the field. Check this for how to create controller extension in visualforce page
http://ccoenraets.github.io/salesforce-developer-workshop/Creating-a-Controller-Extension.html
Jagadeesh AdaveniJagadeesh Adaveni
Alreay for Save button i have some other logic. Can i write that logic in my save method if yes Could you please give me brief code