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
SreejbSreejb 

How to refer each text box from vf page with database object?

Hi Friends,

I am new to vf page development. I have custom object Time_entry_details. Fields are Activity__c, Hour__c Date__c and lookup field to time_entry__c.

My vf Page look like this

User-added image

Here Activity is picklist and other columns are (SUN to SAT) Input text boxes.

Scanario is

I select one activity and enter hours in monday wednesday text box in any row. If i click on save button it should save in time_entry_details__c object. while retriving the record it should show in the same text boxes.

Question is

How to refer each text box to object. I am thinking in background we need to give some unique reference.... like in excel cell (A1,A2,A3...Like). How to do like that? If i am wrong please lead me.

Herewith attached my vf page and controller. Please give me solution.
 
<apex:page showHeader="false" sidebar="false" controller="timeentrydetails" >
    <apex:form >
        <apex:pageBlock title="Time Entry Details Page - {!$CurrentPage.parameters.startDate} - {!$CurrentPage.parameters.endDate} ">
            <apex:pageBlockButtons location="top" >
                <apex:CommandButton value="Save" action="{!save1}"/>
                <apex:CommandButton value="Submitted"/>
                <apex:CommandButton value="Addrows" action="{!addrows5}" reRender="row"/>
                <apex:CommandButton value="Back" action="{!back1}"/>
            </apex:pageBlockButtons>

             
            <apex:pageBlockTable id="row" value="{!Tedt_list}" var="i">
                <apex:column headerValue="Activity" >
 
                                    <apex:selectList multiselect="false" size="1" >
                                        <apex:selectOption itemValue="--Select--" itemLabel="--Select--"/>
                                        <apex:selectOption itemValue="Analysing" itemLabel="Analysing"/>
                                        <apex:selectOption itemValue="Designing" itemLabel="Designing"/>
                                        <apex:selectOption itemValue="Code Developing" itemLabel="Developing"/>
                                        <apex:selectOption itemValue="Testing" itemLabel="Testing"/>
                                    </apex:selectList>
                               </apex:column>             

                       <apex:column headerValue="SUN">
                       <apex:inputText size="10" />
                       </apex:column>
                       
                       <apex:column headerValue="MON">
                       <apex:inputText size="10" />
                       </apex:column>
                       
                       <apex:column headerValue="TUE">
                       <apex:inputText size="10" />
                       </apex:column>
                       
                       <apex:column headerValue="WED">
                       <apex:inputText size="10" />
                       </apex:column>

                       <apex:column headerValue="THU">
                       <apex:inputText size="10" />
                       </apex:column>
                       
                       <apex:column headerValue="FRI">
                       <apex:inputText size="10" />
                       </apex:column>
                       
                       <apex:column headerValue="SAT">
                       <apex:inputText size="10" />
                       </apex:column>
                      
                
            </apex:pageBlockTable>
        
        </apex:pageBlock>
    
    
    </apex:form>
      
 
</apex:page>

Controller is
 
public class timeentrydetails {


    Public Class Tedrow{
        Public Id Tedid {get;set;}
        Public Id Teid {get;set;}
        Public Date Date1{get;set;}
        Public String Activity {get;set;}
        Public Integer Hour {get;set;}
        Public String Uniid {get;set;}
        Public String Day {get;set;}
    
    }
    
  
     public List<Time_Entry_Detail__c> Tedt_list {get;set;} 
     public List<Tedrow> Tedrow_list {get;set;} 
     
    Public timeentrydetails(){
    
        string teid = apexpages.currentpage().getparameters().get('id').trim();
        system.debug(teid);
        string tesdate = apexpages.currentpage().getparameters().get('startDate');
        system.debug(tesdate);
        string teedate = apexpages.currentpage().getparameters().get('endDate');
        system.debug(teedate);
        Tedt_list = new List<Time_Entry_Detail__c>();
        Tedrow_list  = new List<Tedrow>();
        Tedrow Tedrow_item = new Tedrow();
        
        if(teid!=null && teid!= '')
        {
            id timedetailid = (id) teid;
            Tedt_list = [select id, name,Time_Entry__c,Activity__c,Date__c,Hour__c,Date_Day_value__c FROM Time_Entry_Detail__c where Time_Entry__c =:timedetailid and ownerid =:userinfo.getuserid() limit 150];
        }

        for(integer i=Tedt_list.size();i<5;i++)
        {
             Time_Entry_Detail__c tedt = new Time_Entry_Detail__c();
             Tedt_list.add(tedt); 
        }      
  
        for(Time_Entry_Detail__c ted_item  :Tedt_list )
        {
               Tedrow_item.Activity  = ted_item.Activity__c;
               Tedrow_item.Date1=ted_item.Date__c;
               Tedrow_item.hour = (integer) ted_item.Hour__c;
               Tedrow_item.day = ted_item.Date_Day_value__c; //checking if date is not null
               Tedrow_item.Tedid  = ted_item.id;
               Tedrow_item.Teid = ted_item.Time_Entry__c;
        }
}

Public void addrows5(){
     
  for(integer i=0;i<5;i++)
            {
             Time_Entry_Detail__c tedt = new Time_Entry_Detail__c();
             Tedt_list.add(tedt); 
            }
}
 

public PageReference back1() {

    PageReference reRend = new PageReference('/apex/timeentryexp');
    reRend.setRedirect(false);
    return reRend;

}

Public void save1(){



}








}