+ Start a Discussion
vikramkkvikramkk 

Input text in PageBlock table column

 

I am displaying a list of values in one of the columns in a page block table from a list(returned from a query). But in the other two columns I want to use input text tags to enter values by users. The condiiton is I want to insert those recors in the list to the database. In other words

 

Name            Address                                                         Email

Jon                input text (user enter some value)            input text (user enter some value)

Glenn            input text (user enter some value)            input text (user enter some value)

Tom               input text (user enter some value)             input text (user enter some value)

 

I want to insert record with values Name as Jon and Address and Email values entered by user. Similarly ecord with values Name as Glenn and Address and Email values entered by user and ecord with values Name as Tom and Address and Email values entered by user. (The names Jon, Glenn, Tom are retuned from a query and stored in a list and I am assigning page block table value attribute to that list. ) How can I insert those records with some values input by user( columns Address and Email)  and some (Name column-returned from a query)

 

Many thanx

Vikram

 

 

Navatar_DbSupNavatar_DbSup

Hi,

Try the below code snippet as reference:

 

------------------------- Vf page----------------

<apex:page controller="dipslayinputtextinpageblocktable" >

  <Apex:form >

  <Apex:pageBlock >

      <apex:pageblockTable value="{!con}" var="c" >

      <apex:column ><apex:facet name="header">Name</apex:facet>{!c.name}</apex:column>

      <apex:column ><apex:facet name="header">Mailing City </apex:facet><apex:inputField value="{!c.mailingcity}" /></apex:column>

      <apex:column ><apex:facet name="header">Email</apex:facet><apex:inputField value="{!c.Email}" /></apex:column>

     

     

     

      </Apex:pageblockTable>

 

  <apex:commandButton value="Save" action="{!updatecon}" />

  </Apex:pageBlock>

 

  </Apex:form>

</apex:page>

 

------------------------------ Apex Controller ------------------------

public class dipslayinputtextinpageblocktable

{

public list<contact> con{get;set;}

public dipslayinputtextinpageblocktable ()

{

    con=[select name,mailingcity,email from contact limit 10];

}

public void updatecon()

{

    if(con.size()>0)

    {

        update con;

    }

}

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

vikramkkvikramkk

Hi

 

Thanks for the reply. I want to use inputtext tag but not input field. Therefore we can relate input text just like we can do wih input field. The input text values of Address and Email along with value of Name which is returned from the query need to be inserted in to data base as one record. This is the requirement.

 

Thanks