You need to sign in to do that
Don't have an account?
jayam
Accessing list<sobject> in vf page
hi,
I got an error named 'Unknown property 'SObject.name' 'when Accessing the list<sobject > in my vf page .
Here is my code .
in Apex class
list<sobject> get names(){
list<sobject> objlist=[select name from Contact];
return objlist;
}
in vf page
<apex:datatable value="{!names}" var="a" >
<apex:column>{!a.name}</apex:column>
</apex:datatable>
what can I do?
thanks........
hi!
must be like this "public list<sobject> getnames()"
Hi, object properties are evaluated at compile time and i dont think sobject support "name" property you have to type cast it in contact, prior to bind with visualforce. If you must have to use sobject then you can use inner classes to associate generic properties.
Thanks,
Lakhan
Hi
Thanks for your reply lakhan
But now I have to know how to use innner classes .
if u know you can send example to me.
thanksssssss
Hi Jayam,
I am uncertain about why do you want the output of (concrete sObject) contact in List<sObject>, you could simply use List<Contact> then there would not be any problem related to unknown property.
However for your reference if you have to use dynamic query where type of sObject is uncertain it can be handled in other way like-
Thanks,
Lakhan
Thanks Lakhan ,
I Solved my Problem ,
Thank you very much Lakhan .....