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
suresh goudsuresh goud 

How to display table to store static data?

Hi ,

 

   I am writing visualforce page. i would like to draw a table which is having 10 rows and 3 columns with header for each.

When user enter data it has to store data as a record.

 

I have tried with dataTable tag .....check my code below..

 

<apex:page standardController="Account">
<apex:form >
<apex:pageMessages />
<apex:pageblock title="Foreign exchange information">
<apex:pageblockButtons >
<apex:commandButton value="Save" action="{!save}"  title="Save" />
<apex:commandButton value="Cancel" action="{!cancel}"  title="Cancel"/>
</apex:pageblockButtons>

 <apex:pageBlockSection title="Special pricing agreements">
  <apex:dataTable align="right" value="{!Account}"  rows="10" columns="3" var="a" rendered="true" id="theTable" cellpadding="3" cellspacing="3">
 
<apex:column >
<apex:facet name="header"> Client Name</apex:facet>
<apex:inputtext value="{!a.test__c}"/>
</apex:column>

<apex:column >
<apex:facet name="header">Account</apex:facet>
<apex:inputtext value="{!a.name}"/>
</apex:column>

<apex:column >
<apex:facet name="header">Notes</apex:facet>
<apex:inputtext value="{!a.test2__c}"/>
</apex:column>

</apex:dataTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

But it is able to display only 1 row and 3 columns but not 10 rows.

 

Please help me to do this functionality.

 

Thanks,

Suresh Goud

 

Starz26Starz26

Are you using a custom controller or extension? If not the VF page will default to returning only the account record associated with the ID paramater in the url calling the VF page.

 

If you want to return a list of accounts you will have to write an extension to the standard account controller

hemantgarghemantgarg

you need to bind the data table value to a list of accounts from the custom controller or extension .