Cascading Dropdown in LightSwitch 2012 - Part 1

Here we will see how to create tables as well as establish relationships among tables in LightSwitch using Visual Studio 2012.

This article describes how to establish a relationship among tables.

Step 1

Open the Solution Explorer.

sol exp.jpg

Step 2

In the Solution Explorer, right-click on the Server and choose "Add Table". 

Add table.jpg

Step 3

Here we will add three tables.

Company Table

company.jpg

Employee Table

employee table.jpg

Project Table

project table.jpg

Step 4

Now we are going to add a relationship among the tables.

To add relationships among the tables, go to the menu bar and click on the "Add Relationship" button.

relationship button.jpg

The Add New Relationship dialog box appears. In that, establish the relationship in such a way that one Company can have more than one Employee.

company employee rel dialog.jpg

One Employee can have more than one project.

employee project rel dialog.jpg

Step 5

In the Solution Explorer, right-click on the Screens and choose Add Screen.

Add src.jpg

The Add New Screen dialog box appears. Select the "Editable Grid Screen" from the Screen Template, under screen information, choose "Company" under screen data and provide a name to the Screen and click the "OK" button.

editable company src.jpg

In this way we will add two more Editable Grid Screens, one for Employee and another one for the project.

editable Employee src.jpg

The Editable Project Screen is shown below.

editable project src.jpg

Step 6

Press F5 to run the application. 

companies output.jpg

The output for the Editable Employee Grid:

employees output.jpg

The output for the Editable project Grid is shown below.

project output.jpg