Articles → LIGHT SWITCH 2011 → Create Cascading Dropdowns In Lightswitch 2011
Create Cascading Dropdowns In Lightswitch 2011
Software Requirement
- Visual studio 2010 is installed on your machine.
- Visual Studio 2010 service pack 1 is installed on your machine.
- Microsoft Visual Studio Light switch 2011 is installed on your machine.
Prerequisite Knowledge
- What is lightswitch?
- What are screens and entities in lightswitch?
- How to create an entity in lightswitch?
- How to create a screen in lightswitch?
- How to add relationship between the entities?
Scenario For Cascading Dropdown
Creation Of Tables
Click to Enlarge
Add Relationship Between Tables
- One country can have more than one states
- One state can have more than one cities.
Click to Enlarge
Click to Enlarge
Add Data Into The Tables
Click to Enlarge
Add Queries On Tables
- Right click on States table and click on Add Query.
- Designer window opens up. Change the name of the query by clicking on it
- Click on the button + Add Parameters.
- Enter the parameter name and its data type.
- Click on + Add Filters and add where condition.
Click to Enlarge
Click to Enlarge
Click to Enlarge
Add Screen For Cascading Dropdown
Click to Enlarge
Click to Enlarge
Add Queries And Entities On The Screen
- Click on Add Data Item…
- A popup window will appear
- Select the query GetStates.
- Click Ok
Click to Enlarge
- Again click on Add Data Item…
- This time select GetCities
- In the similar way select GetCountry queries.
- Once the queries are added, it is the time to add entities for country, state and city.
- To add an entity click on Add Data Item….
- A popup window will appear.
- Click on Local Property radio button.
- Select Country entity.
Click to Enlarge
- Similarly add State and City entity.
Click to Enlarge
Bind Query Parameters
- Click on Query Parameters CountryID in GetStates query and press F4.
- In the Parameter Binding field add the name of the parameter as shown in figure below
Click to Enlarge
- Similarly enter Parameter Binding field for StateID in GetCities query.
Click to Enlarge
Adding Country, State And City Data Item
Click to Enlarge
Change Choicelist
- Click on State drop down and press F4.
- In the property window select GetStates option from Choices.
Click to Enlarge
- Similarly for Cities select GetCities option.
Click to Enlarge
- And for country select GetCountry option
Click to Enlarge
Output
Click to Enlarge