You need to sign in to do that
Don't have an account?

How will you display a custom object field using custom controller
I have a custom object. And I have a field Name and ID.. How can I display these fileds in Visual Force page, using custom controller.
Thank you in advance.
Thank you in advance.
Sample Apex class
public with sharing class customController {
public list<customobject__c> objlist {get;set;}
Public VFC_customController(){
objlist = [Select Id, Name from customobject__c]; // Use where condition if you want
}
Sample Visualforce Page
<apex:page Controller="customController">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection>
<apex:pageBlockTable Id="allcon" value="{!objlist}" var="ans" rendered="{!If(objlist != null,True,False)}" width="100%">
<apex:column ><apex:facet name="header">id</apex:facet>
<apex:outputfield value="{!ans.id}"></apex:outputfield>
</apex:column>
<apex:column > <apex:facet name="header">Name</apex:facet>
<apex:outputLink Value="/{!ans.Id}">
<apex:outputfield value="{!ans.Name}"></apex:outputfield></apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form >
</apex:page>
All Answers
Sample Apex class
public with sharing class customController {
public list<customobject__c> objlist {get;set;}
Public VFC_customController(){
objlist = [Select Id, Name from customobject__c]; // Use where condition if you want
}
Sample Visualforce Page
<apex:page Controller="customController">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection>
<apex:pageBlockTable Id="allcon" value="{!objlist}" var="ans" rendered="{!If(objlist != null,True,False)}" width="100%">
<apex:column ><apex:facet name="header">id</apex:facet>
<apex:outputfield value="{!ans.id}"></apex:outputfield>
</apex:column>
<apex:column > <apex:facet name="header">Name</apex:facet>
<apex:outputLink Value="/{!ans.Id}">
<apex:outputfield value="{!ans.Name}"></apex:outputfield></apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form >
</apex:page>
Public VFC_customController() : Invalid constructor name
Public VFC_customController() : Invalid constructor name