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
Gopal yadav (ASY)Gopal yadav (ASY) 

want to use method name instead of object name in vf page

vf page:-

<apex:page StandardController="Student__c" extensions="StudentController" tabStyle="Contact">
    <apex:slds />
    <apex:form >
        <apex:pageBlock title="Student Details">
            <apex:pageBlockSection title="Student Interface" columns="2">
                <apex:pageBlockSectionItem >
                    <div></div> 
                    <apex:outputLabel > Student Name
                        <apex:inputField styleClass="slds-input" value="{!Student__c.Name}"/>
                    </apex:outputLabel>               
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <div class="slds-align_absolute-center"></div>
                    <apex:outputLabel >Student Id
                        <apex:inputField styleClass="slds-input" value="{!Student__c.Student_ID__c}"/> </apex:outputLabel>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <div class="slds-align_absolute-center"></div>
                    <apex:outputLabel >Batch
                        <apex:inputField styleClass="slds-input" value="{!Student__c.Batch__c}"/></apex:outputLabel>
                </apex:pageBlockSectionItem>                   
                <apex:pageBlockSectionItem >
                    <div class="slds-align_absolute-center"></div>
                    <apex:outputLabel >Section
                        <apex:inputField styleClass="slds-input" value="{!Student__c.Section__c}"/> </apex:outputLabel>
                </apex:pageBlockSectionItem>              
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Student Functions" columns="1">
                <apex:pageBlockSectionItem >                   
                    <apex:pageBlockTable value="{!Student__c}" var="s" title="Marks" rows="1">
                        <apex:facet name="header">Marks</apex:facet>
                        <apex:column > 
                            1sem
                            <apex:facet name="header">Serial Number</apex:facet>                       
                        </apex:column>                   
                        <apex:column >                       
                            <apex:inputField value="{!s.Maths__c}"/>
                            <apex:facet name="header">Maths</apex:facet>                       
                        </apex:column>
                        <apex:column >
                            <apex:inputField value="{!s.English__c}"/>
                            <apex:facet name="header">English</apex:facet>
                        </apex:column>
                        <apex:column >
                            <apex:inputField value="{!s.Science__c}"/>
                            <apex:facet name="header">Science</apex:facet>
                        </apex:column>
                        <apex:column >
                            <apex:inputField value="{!s.Total__c}" required="true"/>
                            <apex:facet name="header">Total</apex:facet>
                        </apex:column>                   
                    </apex:pageBlockTable>
                </apex:pageBlockSectionItem>               
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!save}"/>  
            </apex:pageBlockButtons>         
        </apex:pageBlock>       
    </apex:form>   
</apex:page>




and controller is:-

public with sharing class StudentController {
    public Student__c admin{ get; set; }
    public ApexPages.StandardController stdCtrl;
    public StudentController(ApexPages.StandardController controller) {
        stdCtrl = controller;
    }
    
    public PageReference save() {
        admin=(Student__c)stdCtrl.getRecord(); 
        upsert admin;  
        system.debug(admin);
        PageReference pageRef = new ApexPages.StandardController(admin).view();
        pageRef.setRedirect(true);
        return pageRef;
    }
}





everything is working fine but the proble is i want to use method name in vf page as "admin" instead of custom object name "Student__c"  as admin.Name  not Student__c.Name

plzz help me in editing my code
Sanjay Bhati 95Sanjay Bhati 95
Hy Gopal yadav (ASY)

You can use admin instead of Student__c.Name on vf page 
 you are doing this :
  <apex:inputField styleClass="slds-input" value="{!Student__c.Name}"/>

But you can use like this :
<apex:inputField styleClass="slds-input" value="{!admin.Name}"/>

Thanks