You need to sign in to do that
Don't have an account?
HIRAL PUROHIT
How to create pageBlockTable in custom object
I have created app related to university.In this for Student object I need to show some information in one table with 4 columns.
Please guide me how to create table in custom object using Visualforce.
Here I am posting my code which I tried.
<apex:page Controller="Student">
<apex:pageBlock title="Course Details">
<apex:pageBlockTable value="{!Student_c}" var="stu">
<apex:column value="{!stu.Sr_no__c}"/>
<apex:column value="{!stu.Course_1__c}"/>
<apex:column value="{!stu.Professor__c}"/>
<apex:column value="{!stu.Final_Grade__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
----------------------------------------------------------------------
Error: Unknown property 'String.Sr_no__c'
Thanks.
Please guide me how to create table in custom object using Visualforce.
Here I am posting my code which I tried.
<apex:page Controller="Student">
<apex:pageBlock title="Course Details">
<apex:pageBlockTable value="{!Student_c}" var="stu">
<apex:column value="{!stu.Sr_no__c}"/>
<apex:column value="{!stu.Course_1__c}"/>
<apex:column value="{!stu.Professor__c}"/>
<apex:column value="{!stu.Final_Grade__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
----------------------------------------------------------------------
Error: Unknown property 'String.Sr_no__c'
Thanks.
To show the data in the table from the object your controller should look as below.
public class Student {
public list<Student__c> getStudent_c() {
//your business logic
}
}
Ex. consider a scenario where you want to show all the record from Student__c then your controller should look as below.
public class Student {
public list<Student__c> getStudent_c() {
return [select Sr_no__c, Course_1__c, Professor__c, Final_Grade__c from Student__c];
}
}
If this helps you in solving your problem then mark it as Best Answer.
All Answers
I am assuming that the method getStudent_c in your custom controller is not returning the proper list type.Kindly have a look in that(it should look alike list<Student__c>).
And if this is not the issue then share your controller code.
P.S. if above-mentioned solution helps you then mark it a Best Answer.
public class Student {
public String getStudent_c() {
return null;
}
-----------------------------------------------
it's showing following error:
Error: Unknown property 'String.Sr_no__c'
please help with this.
To show the data in the table from the object your controller should look as below.
public class Student {
public list<Student__c> getStudent_c() {
//your business logic
}
}
Ex. consider a scenario where you want to show all the record from Student__c then your controller should look as below.
public class Student {
public list<Student__c> getStudent_c() {
return [select Sr_no__c, Course_1__c, Professor__c, Final_Grade__c from Student__c];
}
}
If this helps you in solving your problem then mark it as Best Answer.
Thank you so much Snjeev and Lakshman for your help.
One more thing please....
I want to show this table to my Students tab(Object:Student).I created a section named course details on Student object,in this section I want to show this table.So how can I use my visualforce code there?
I tried overriding by using 'Buttons, Links, and Actions' but then it's come up with just a one section(only VF code).
I have two section in my tab (1. Student Detail ,2.Course Detail) . And I want to replace this Course Details section with my VF code. And want to keep Student Detail section as it is.