A common question that I’ve run into again lately is how can I set the Selected or Selected Text property of a dropdown control in a Canvas App when there is NO Selected property? The key to solving this problem is understanding the interaction between two other aspects in Power Apps. They are the default property of the Dropdown and the Reset() function in Power Apps. Lets look at how each of these work and how they interact.
Dropdown Default Property
Setting the initial value in a dropdown is as easy as setting the default property of the control. When the control first loads it will look at the default property to set the initial value of the controls. The problem is that once a user has interacted with the control the default setting will be ignored. This is where the Reset() function comes in.
The Reset() function in Power Apps is specifically designed to reset a given control back to their Default settings. Adding Reset(<<DropDown>>); to the end of an OnSelect that Patches or Submits a form will clear the user’s input and reset the Dropdown back to its original default value.
Try it Yourself
- Add a Dropdown and a Button to a Screen in a Power App
- Set the Default property of the Dropdown to “2”
- Type reset(Dropdown1) into the OnSelect Property of the Button
When you run the app the dropdown will default to 2. Use the dropdown to select 3 as the chosen value. Navigate to a different screen and back again. The dropdown will be set to 3. Press the button. The dropdown selected value will change to 2
This functionality works on most controls with minor variations. Its the same for TextInput boxes, but for ComboBoxes you set DefaultSelectedItems to a record containing the value of the default selection.