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
I am ABI am AB 

I am not able to get the values in the edit form. Please help

Visualfrom Page( StudentApp)
<apex:page StandardController="StudentApp__c" extensions="StudentRecord">
  <apex:form >
        <apex:pageBlock title="Student New Record">
              <apex:pageBlockSection title="Student New Record" >
                    
                    <apex:outputLabel value="Phone"></apex:outputLabel>
                    <apex:inputText value="{!StPhone}"/>
                    <apex:outputLabel value="Email"></apex:outputLabel>
                    <apex:inputText value="{!StEmail}" /> 
                    <apex:outputLabel value="Student Name"></apex:outputLabel>
                    <apex:inputText value="{!StName}" />                
              </apex:pageBlockSection>
              <apex:pageBlockButtons >
                <apex:commandButton action="{!insertStudent}" value="{!$Label.SaveStudent}" />
                <apex:commandButton action="{!insertAndNew}" value="Save and New" />
                <apex:commandButton action="{!cancel}" value="Cancel" /> 
              </apex:pageBlockButtons>
         </apex:pageBlock>
    </apex:form> 
</apex:page>
VisualForce Page(ViewStudent)
<apex:page StandardController="StudentApp__c" extensions="StudentRecord" action="{!getStudentInfo}">
  <apex:form >
        <apex:pageBlock title="Student View Record">
              <apex:pageBlockSection title="Student View Record" >
                    
                    <apex:outputLabel value="Phone"></apex:outputLabel>
                    <apex:outputText value="{!StPhone}"/>
                    <apex:outputLabel value="Email"></apex:outputLabel>
                    <apex:outputText value="{!StEmail}" /> 
                    <apex:outputLabel value="Student Name"></apex:outputLabel>
                    <apex:outputText value="{!StName}" />                
              </apex:pageBlockSection>
              
              <apex:pageBlockButtons location="Top">
             <apex:commandButton value="Edit" action="{!UpdateStudent}"/>
         </apex:pageBlockButtons>
              
         </apex:pageBlock>
         
    </apex:form> 
</apex:page>

Controller (StudentRecord )
 
public class StudentRecord {

    public string StName{get;set;}
    public string StEmail{get;set;}
    public String StPhone{get; set;}
    
    public StudentRecord(ApexPages.StandardController controller) {
            }
    
    public StudentRecord(){
    }
    public PageReference insertStudent(){
        
        StudentApp__c st= new StudentApp__c();
        
        st.Name=StName;
        st.StudentEmail__c=StEmail;
        st.StudentPhone__c=StPhone;
        
        insert st;
        
        //StudentApp__c st = [select Id from StudentApp__c where Id = :st.id];
        
        PageReference stPage = new PageReference(Page.studentview.getUrl()+'?Id='+st.Id);
        stPage.setRedirect(true);
        return stPage;
    } 
    
    public PageReference insertAndNew(){
        
        StudentApp__c st= new StudentApp__c();
        
        st.Name=StName;
        st.StudentEmail__c=StEmail;
        st.StudentPhone__c=StPhone;
        
        insert st;
        
        PageReference stPage = new PageReference(Page.studentapp.getUrl());
        stPage.setRedirect(true);
        return stPage;
    }
    
    public void getStudentInfo()
    {
        String id = ApexPages.currentPage().getParameters().get('Id');
        if(id != null)
        {
            StudentApp__c st = [select Id, Name, StudentEmail__c, StudentPhone__c from StudentApp__c where Id = :id];
            stName = st.name;
            StEmail = st.StudentEmail__c;
            StPhone = st.StudentPhone__c;
        }}
                
      public PageReference UpdateStudent(){
                String id = ApexPages.currentPage().getParameters().get('Id');
                if(id != null){
                        StudentApp__c st = [select Id, Name, StudentEmail__c, StudentPhone__c from StudentApp__c where Id = :id];
                                            
                        //System.debug(st.StudentEmail__c);
                        StName=st.Name;
                        StEmail=st.StudentEmail__c;
                        StPhone=st.StudentPhone__c;
                        
                        update st;
                   
                       PageReference vin = new PageReference(Page.studentapp.getUrl()+'?Id='+st.Id);
                       vin.setRedirect(true);
                       return vin;}
                       
                       else{
                             return null;
                            }
                    
        }
    
}

When i am firing an action update button (Edit ), It is successfully redirected to the edit page which is studentapp vf page. But the field is this form are blank. I need them to be filled with the values of the record which is iam passing through the id. 
Please help!
Thanks in advance!
 
D-CoderD-Coder
What is the URL of edit page ? Does it contain "Id" as a parameter ?