The Data Sources represent connections to databases or web services. A screen may have multiple Data Sources.
The following figure summarizes the execution model of a Data Source in an application which shows a list of categories. When the user selects a category a list of deals for the category is presented.
When the first screen loads, it verifies that the List needs to obtain values of the database. It runs the Data Source (being the first screen, it will not have parameters or use the default value of the parameters) and presents the outcome of the query on the List control.
The user clicks on an item of the list, calling the second screen. During loading of this screen it verifies that the list needs other values from the database. It runs the Data Source using as parameter the Id of the previously selected Category.
It runs the Data Source and exposes the query result. The list uses these values to load itself.
The above example shows how to send parameters from one screen to the input parameters of a Data Source on another screen. Another way to run it would be making the same screen to run a Data Source.
In the following case we have a screen that, when loaded, loads a Drop Down List with countries obtained from a database. Selecting one will run another Data Source that will get the country organizations, and load the Drop Down List of Organizations.
As we have seen, the Data Sources can have input parameters. These values may be default values , previous screen values or controls on the same screen.
Note that the way to configure the mapping of the parameters is the same for the database and web services data sources.
The following screen shows the configuration of a Data Source Database. We can see that it has an input parameter, @ProductID. To configure the mapping, you must click "Add Mapping".
By clicking "Add Mapping" a window opens to add where this parameter should get the value. We can select a screen and the control. You can add multiple sources to a single mapping. This covers the case of a screen that is called from multiple screens. In this case we use the value of screen previously executed.
You can also use special values as a mapping source which are not specifically of a control. If you select "[Custom Data]" to "Screen", we see that in "Control" can select the current GPS position.