You need to sign in to do that
Don't have an account?

Passing PickValue to a Variable in Controller method
Can anybody help me in resolving the below issue.
I have written a visualforce page consisting of picklist.When I select a value in the picklist the value should be passed to a variable in controller class.I am not getting the selected value in the variable.
/////////My Visualforce page
<apex:page StandardController="User" id="thePage" Extensions="UserData">
<apex:form >
<apex:pageBlock title="SelectUsers" id="USERSLIST" mode="edit">
<h1>Update Sales Co-ordinator for the users in Particular Region</h1>
<br></br>
Select Region of the User: <apex:inputField id="startMode" value="{!User.Region__c}" />
<br></br>
<apex:commandButton value="Search" action="{!doSearch}" status="myStatus">
</apex:commandButton>
<br></br>
</apex:pageblock>
</apex:form>
//////My Controller
public class UserData {
PUBLIC String usr{get;set;}
PUBLIC List<selectOption> usrs;
List<User> results=new List<User>();
List<Id> userlist=new List<Id>();
String Regionid;
String Region;
public UserData(ApexPages.StandardController controller)
{
}
public Pagereference doSearch()
{
//selected picklistvalue should be passed to the below query
results = [select Name from User Where id=:??????];
system.debug('USERSLISTFOR REGION$$$$'+results);
return null;
}
public List<User> getResults()
{
return results;
}
}
Can anyone please help me in resolving the issue.
Thanks...
Please provide a
Try
results = [select Name from User Where Region__c = :(((User)controller.getRecord()).Region__c)];
You also need to save the controller variable that is passed to the constructor for use in the above query.
Hi,
Thank you for your reply.
Could you please elaborate on "save the controller variable that is passed to the constructor for use in the above query".
The constructor is an empty one and i am not using any variable that is assigned in the controller method.
Thanks.
The constructor argument "ApexPages.StandardController controller" needs to be saved for later use in doSearch method: