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
nani@rnani@r 

I can't do pageblocktable with this code

In this program i have doubt about pageblock table because i can't see details of object .pls solve my problem .

 

but it shows the error "Error: Unknown property  String.price__c" 

 

 

<apex:page standardController="rajesh__c">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:pageMessages ></apex:pageMessages>
<apex:commandButton action="{!save}" value="save"></apex:commandButton>
<apex:commandButton action="{!cancel}" value="cancel"></apex:commandButton>
</apex:pageBlockButtons>

<apex:pageBlockSection >
<apex:inputfield value="{!rajesh__c.name}"></apex:inputfield>
<apex:pageBlockTable value="{!rajesh__c.Name}" var="raj" >
<apex:column value="{!raj.price__c}"></apex:column>
<apex:column value="{!raj.subject__c}"></apex:column>

</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>

</apex:page>

Prafull G.Prafull G.

In the <apex:pageBlockTable> component, you can pass list of primitive or non primitive data types. and the var attribute is used to represent the variable name for each row of the list passes in attribute "value"

 

<apex:pageBlockTable value="{!rajesh__c.Name}" var="raj" >
<apex:column value="{!raj.price__c}"></apex:column>
<apex:column value="{!raj.subject__c}"></apex:column>

 

The red highlighted value should be a list which has the Price and Subject as fields on it.

 

Let me know if it helps.

nani@rnani@r

No sir there is nothing change it shows same problem 

nani@rnani@r

can u tell me clear idea about PAGEBLOCK TABLE WITH EXAMPLES pleas solve my problem iam too confusing .

nani@rnani@r

why he assgins the "contacts" to the   account 

Prafull G.Prafull G.
Account.Contacts is a List of Contact Records for a particular Account.

Understand it as...
You have a controller class (Apex Class). In this class you have a variable as
List<Contact> listContacts {get; set;}
you are getting contacts using a SOQL something like
listContacts = [SELECT Id, Name, Email FROM Contact];

Now you can use this list to render in table using pageblocktable..something like

<apex:pageBlockTable value="{!lsitContacts}" var="c">
<apex:column value="{!c.Name}"/>
<apex:column value="{!c.Email}"/>
</apex:pageBlockTable>


Let me know if it helps!

-P