Display all the fields of a sObject using Apex & Visualforce Page

Apex Code:

public class  DisplayAllFieldsClass {
 
     public map<string,schema.sobjectfield> data {get;set;}
   
     public  DisplayAllFieldsClass (){
         data = Schema.SObjectType.BISWAJEET__Student__c.fields.getMap();
     }
}

Visualforce Page Code:

<apex:page doctype="html-5.0" showheader="false" controller="DisplayAllFieldsClass">
    <apex:datatable value="{!data}" var="d">
             <apex:column headervalue="Field Name">
                 {!d}
             </apex:column>         
         </apex:datatable>
</apex:page>

Leave a Reply