+ Start a Discussion
Rick RollRick Roll 

N>Adding VF url ID to Dynamic Selectlist after page load

Hello Guys !!!
After I clicked Edit from my visualforce page, I get redirected to my next page that contains a dynamic selectlist and its url containing an id
ex. https://salesforce_instance/apex/MySecondPage?id=001D000000IRt53

my problem is I want to add that dynamic ID (in this case its "001D000000IRt53" ) in my dynamic selectlist as default selected value
How to code this?
 
James LoghryJames Loghry
Short answer is "It depends."

If you're using an extension controller for instance, you could do something like the following, where you grab the Id from page parameters and then set the dynamic select list's value in the constructor of your controller.
 
public PageReference MyExtensionConstructor(ApexPages.StandardController ctrl){
    Id recordId = ApexPages.getParameters().get('id);
    //OR..
    //Id recordId = ctrl.getId();
    
    myDynamicListSelectedValue = recordId;
}

That should get you started, but if you still need help, feel free to post your Visualforce and Apex here so that we can help a bit more (remember to use the < > button for any code you paste)