+ Start a Discussion
Vidhyasagaran MuralidharanVidhyasagaran Muralidharan 

Problem in sobject describe

Public Class vfcontrol{
public List<selectoption> selectedObject {get; set;}
public vfcontrol()
{
selectedObject = new List<selectoption>();
}
Public void Objectnames()
{
for(Schema.SObjectType objTyp : Schema.getGlobalDescribe().Values()){
String name = objTyp.getDescribe().getName(); 
selectedObject.add(new SelectOption(name));
}
}
}
Error:Compile Error: Constructor not defined: [System.SelectOption].<Constructor>(String
Best Answer chosen by Vidhyasagaran Muralidharan
vmanumachu1.393650924860069E12vmanumachu1.393650924860069E12
select option constructor takes two parameters as input. 1. Option Label 2. Option Name. So change to the below. It should work. Mark as best answer if it works for you. It helps others.

selectedObject.add(new SelectOption(name,name));