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

value binding with fields

Hi there,

               i need a table with 4 columns and 3 rows with manual entry of data and i wrote a code like this


<apex:pageBlockSection title="EDUCATION">
  <table border="1">
      <td>Year Granted</td>
      <td>Degree Granted</td>
      <td><input type="text" value="{!e.College_University__c}"/></td>
      <td><input type="text" value="{!e.Year_Granted__c}"/></td>
      <td><input type="text" value="{!e.Degree_Granted__c}"/></td>
      <td><input type="text" value="{!e.Major__c}"/></td>
      <td><input type="text" value="{!e.College_University1__c}"/></td>
      <td><input type="text" value="{!e.Year_Granted1__c}"/></td>
      <td><input type="text" value="{!e.Degree_Granted1__c}"/></td>
      <td><input type="text" value="{!e.Major1__c}"/></td>
      <td><input type="text" value="{!e.College_University2__c}"/></td>
      <td><input type="text" value="{!e.Year_Granted2__c}"/></td>
      <td><input type="text" value="{!e.Degree_Granted2__c}"/></td>
      <td><input type="text" value="{!e.Major2__c}"/></td>



i got a table with 3 empty rows,

now i need to bind these row values to fields in object,how can i do that can any one suggest me.



Best Answer chosen by Admin (Salesforce Developers) 

This is probably because you are inside a pageblocksection - try closing that before your table markup.

All Answers




You can use <apex:inputField> instead of <apex:inputText> if you need to bind the values.


Let me know if it works for you!



Rather than using <input type="text" ..., use <apex:input> components - that will bind the input to the field in the sobject from the controller




      <td><apex:inputField value="{!e.College_University__c}"/></td>
      <td><apex:inputField value="{!e.Year_Granted__c}"/></td>
      <td><apex:inputField value="{!e.Degree_Granted__c}"/></td>
      <td><apex:inputField value="{!e.Major__c}"/></td>

 You'll also need to wrap all of the input elements in an <apex:form> component to allow postback of the values.


if am using inputfield i am again getting lable and textbox in a table row table structure is damaging.


This is probably because you are inside a pageblocksection - try closing that before your table markup.

This was selected as the best answer

No i have already tried inputfield its not working ...if possible suggest me anyother way of dng that.


Input field is the preferred way, as it will handle different types of input for you.


You do have the option to use <apex:inputText> components in the same way, but that will only allow you to input into a small text field:


      <td><apex:inputText value="{!e.College_University__c}"/></td>
      <td><apex:inputText value="{!e.Year_Granted__c}"/></td>
      <td><apex:inputText value="{!e.Degree_Granted__c}"/></td>
      <td><apex:inputText value="{!e.Major__c}"/></td>



Thanks for your co-operation my problem is solved its with pageblocksection only.


Thank you Very Much.