Data Controllers / Fields

  Items Data Controller

Table of Contents
Data Controllers / FieldsPrint||
Items Data Controller

The Items Data Controller property allows the population of lookup values from another controller in the web app.

For example, suppose that you have configured the static lookup items for Reorder Level field in the Products table of Northwind database.

Reorder Level drop down list with static values.

Providing a list of static lookup items offers many advantages, such as limiting user input while providing a clear list of options.

The functionality can be extended by creating a table to store these values externally. This will allow user management of lookup items.

Creating the Reorder Level Table

Start SQL Server Management Studio. In the Object Explorer, right-click on Databases / Northwind / Database Diagrams, and press New Database Diagram.

Creating a new database diagram for 'Northwind' database in SQL Server Management Studio.

If prompted to create support objects required to use database diagramming, press Yes.

Press 'Yes' to confirm creation of support objects required to use database diagramming.

When the Add Table window appears, select Products table and press Add. Then press Close.

Adding Products table to the diagram.

Right-click on white space and press New Table.

Creating a new table in the database diagram

Enter the name of “ReorderLevels” for the table and press OK.

Assigning a name of 'ReorderLevel' for the new table.

Give this table the following columns:

Is Primary Key Column Name Data Type Allow Nulls
Yes ReorderLevelNumber smallint No
No ReorderLevelText nvarchar(50) No

Save the diagram.

In the Object Explorer, right-click on Databases / Tables / dbo.ReorderLevel node, and press Edit Top 200 Rows.

Context menu option 'Edit Top 200 Rows' for ReorderLevel table in the Northwind database.

Insert the following rows:

ReorderLevelNumber ReorderLevelText
0 Zero
5 Five
10 Ten
15 Fifteen
20 Twenty
25 Twenty-five
30 Thirty

Go back to the database diagram. Drag ReorderLevelNumber column from ReorderLevel table onto ReorderLevel column in Products table.

Creating a foreign key relationship between Products and ReorderLevel tables.

Confirm that the right fields are configured and press OK twice to save the foreign key relationship.

Foreign key relationship between Products and ReorderLevel tables.

Finally, add the controller to the project by refreshing the project settings with ReorderLevel table selected.

Refreshing the project to add ReorderLevel table.

Configuring the Lookup

Start the Project Designer. In the Project Explorer, expand Products / Fields /  ReorderLevel field n0de. Highlight all items underneath the field node, right-click, and press Delete.

Deleting static lookup items for 'ReorderLevel' field.

Double-click on Products / Fields / ReorderLevel node.

'ReorderLevel' field in Products controller.

Change the Items Data Controller in order to populate the dropdown with data from the selected controller:

Property Value
Items Data Controller ReorderLevel

Press OK to save. On the toolbar, press Browse.

Navigate to the Products page, and edit a record. The Re0rder Level field will be populated with values from the ReorderLevel controller.

'Reorder Level' field is populated with values from 'ReorderLevel' table.

Values can be added, edited, or deleted by navigating to the Reorder Level page.

Creating a new Reorder Level record.

Note that using Drop Down List is not the most efficient way to render a lookup – the client library will populate the drop down when the form is initialized. If the controller has a lot of data, it may impact the database server. It would be more advisable to use Auto Complete or Lookup style.