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
tganikumartganikumar 

Dynamically add columns to the pageblock table

I have one object

object__c

if I am giving as input it should add 10 input fields to the pageblocktable and when i am clicking the save, it should save 10 values in the database. If I am giving 5 so it should add 5 input text to the pageblocktable in the visualforce page and 5 values should save in the database.Based on the input number dynamically the columns should add to the pageblocktable.


Any help is greatly appreciated

bob_buzzardbob_buzzard

I wrote a blog post on exactly this topic a while ago:

 

http://bobbuzzard.blogspot.co.uk/2011/07/managing-list-of-new-records-in.html

Raj.ax1558Raj.ax1558

Make a function in a class, that call on button click. 

 

In this function make a for loop and in this loop make a new insatance of object. like

 

public list<object__c> dynamiclist {get;set;}

 

public void addRows()

{

   integer i;

  for(i = 0 ; i<5; i++)

  {

         object__c obj = new object__c();

         dynamiclist.add(obj);

  }

}

 

 

this i value you will set by a page and dynamic list is bind with <apex:repeat> in visualforce page.

 

* Mark this as solution for others to get it easily

 

 

Thank You