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

using of wrapper class can we pass field values dynamically??

Hi Everyone,



i need to develope an apex component in such a way that it should create a pageblocktable by taking object name ,fields name dynamically.For this i written a controller but it is not make my approach is i'm trying to retrieve field names from wrapper class,object name dynamically from database.query and i will bind this wrapper to my page block table.
 Can anyone help this scenario with some sample code please guys??
Shikha AgashiShikha Agashi
Can you please paste your code here as well as please explain little bit what you are trying to do there?
Parteek Kumar 5Parteek Kumar 5
Hi Neeru,

If u want to get object name and fields name dynamiclly, I beleive you should use field set for your requirment.

please check below links... (

sandeep reddy 37sandeep reddy 37
yo its possible  
 see this is the  prog
first class
public class dynamicsoql {
    public string aname{set;get;}
    public string aindustry{set;get;}
    public string query{set;get;}
    public list<account>accc{set;get;}
    public void show(){
        query='select id,name,industry from account';
        if((aname!='' && aname!=null) && (aindustry!=null && aindustry!='')){
           query=query +' where name=\''+aname+'\' and industry=\''+aindustry+'\'';


if(aname!=null && aname!=''){ 

query=query+' where name=\''+aname+'\''; 

else if(aindustry!=null && aindustry!=''){ 

query=query+' where industry=\''+aindustry+'\''; 

the vf
page is
<apex:page controller="dynamicsoql">
    <apex:form >
        <apex:pageBlock title="my search">
            <apex:inputText value="{!names}"/>
            <apex:commandButton value="search" action="{!name}" /><br/><br/><br/>
            <apex:outputText value="{!names}"/>
let me know it is helpful or not