In this tutorial we will show you how to setup a selection list with options that change dynamically based on option selected in another selection list . We will use the demo database for demonstration. The "Cars", "Trademarks" and "Models" tables will be used in the example.
We'll generate add or edit page for the "Cars" table, in the page two selection lists will be generated for the "Trademark" and "Model" fields using the "SELECT" Edit Tag. When the user choose a trademark in the trademark selection list, the options in the model selection list will be changed accordingly. Only models belonged to the selected trademark will be shown.
Fields in Table "Trademarks"
Fields in Table "Models"
Fields in Table "Cars"
In this example, the "Models" table has an integer field named "Trademark" storing the trademark ID of the model.
Steps to Setup selection list with dynamic options
1. Loading ASP.NET Maker
Open ASP.NET Maker and connect to the demo database.
2. Setting up the selection lists
Click "Cars" table on the Database pane.
Select field "Trademark" and click on [SELECT] on the [Edit Tag Panel]. Check [Use Lookup Table] checkbox on the [Edit Tag] panel and enter the following setting.
To set up child fields, click [Child lookup fields...] and enter the following settings:
[Link field] is the field (in lookup table) whose value is actually saved. In this example, the field value of Models.ID (NOT Models.Model) will be saved to the field Cars.Model.
[Filter field] is the field (in lookup table) by which the lookup table records are filtered. Only records with a Filter field value matching the selected value of the parent selection list will be shown. In this example, only models with Trademark field value matching the selected Trademark ID in the parent selection list are shown.
Click [OK] to confirm.
If you now select the Model field, you'll see:
3. Generating ASP.NET Script
Click the [Generate] button and ASP.NET Maker will generate the required ASP.NET scripts automatically.
4. Running the ASP.NET Application
Click on the link to the "Cars" table and go to the Edit page. The options in the model selection list will be changed automatically when the selected option in trademark selection list is changed: