You need to sign in to do that
Don't have an account?
Ankit Singhal
Creating a dropdown on Visualforce Page with values as Users.
Hi Everyone,
I need to create a dropdown field on Visualforce page which should display the list of Users based on a query.
Then I need to use the chosen value in my Controller.
How to achieve this??
Plz help its urgent
Thanks,
Ankit
Hi Ankit,
Try following code
Visualforce page
Controller
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Hi Ankit
I wish this code should be helpfull for you.
Your apex visual force Page
<apex:page controller="userController">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection>
<apex:OutputPanel >
<apex:selectList value="{!selecteduserId}" size="1" multiselect="false" >
<apex:selectOptions value="{!ListOfUser}" />
</apex:selectList>
</apex:OutputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex class code:-
public with sharing class userController
{
//This variable hold the id of user which is selected by enduser from picklist
public String selecteduserId {set;get;}
//This var hold List of user
public List<SelectOption> getListOfUser()
{
List<User> Users = [select id ,Username,name from user] ;
List<SelectOption> UserOptionList = new List<SelectOption>();
UserOptionList .add(new SelectOption( ' ' ,'---Select---'));
for(User u : Users )
{
UserOptionList .add(new SelectOption(u.Id , u.Name));
}
retrun UserOptionList ;
}
public userController()
{
selecteduserId ='';
}
}
Thanks
i want to give input to sheduler through visulaforce page by dropdownlist, any one can calp me,
regards