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
deepu.sandeepdeepu.sandeep 

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">
     <tr>
      <td>College/University</td>
      <td>Year Granted</td>
      <td>Degree Granted</td>
      <td>Major</td>
     </tr>
     <tr>
      <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>
     </tr>
     <tr>
      <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>
     </tr>
     <tr>
      <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>
     </tr>
     
  </table>   
   
</apex:pageBlockSection>

 

 

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) 
bob_buzzardbob_buzzard

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

All Answers

nick1505nick1505

Hi, 

 

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

 

Let me know if it works for you!

 

bob_buzzardbob_buzzard

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

 

E.g.

 

   <tr>
      <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>
     </tr>

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

deepu.sandeepdeepu.sandeep

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

bob_buzzardbob_buzzard

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

This was selected as the best answer
deepu.sandeepdeepu.sandeep

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

bob_buzzardbob_buzzard

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:

 

     <tr>
      <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>
     </tr>

 

deepu.sandeepdeepu.sandeep

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

 

Thank you Very Much.