Articles → LIGHT SWITCH 2011 → Bind grid with view in lightswitch 2011

Bind grid with view in lightswitch 2011




























Software requirement











Prerequisite knowledge













Steps for execution























Create a new lightswitch project




Picture showing the project structure of the lightswitch project

Click to Enlarge


Create tables




Picture showing the schema of the Employee table

Click to Enlarge

Picture showing the schema of the Department table

Click to Enlarge


Adding data in the tables




Picture showing the data in the Employee table

Click to Enlarge

Picture showing the data in the Department table

Click to Enlarge


Add data source in lightswitch




Picture showing the context menu with the Add Data Source option

Click to Enlarge



Picture showing the Add data source wizard to select the datasource type

Click to Enlarge



Picture showing setting up the connection string for SQL server database

Click to Enlarge













Picture showing the list of tables in the database

Click to Enlarge



Picture showing the data source added in the lightswitch project

Click to Enlarge


Add view in the database




CREATE VIEW vw_GetEmployeeData AS 
SELECT 
  e.EmployeeId, 
  e.EmployeeName, 
  d.DepartmentName 
FROM 
  Employee e 
  INNER JOIN Department d ON e.DepartmentId = d.DepartmentId



Update data source






Picture showing the context menu of the data source with update datasource option

Click to Enlarge



Picture showing the update data source wizard for adding the view in the data source

Click to Enlarge



Picture showing the warning message when the view is added in the data source

Click to Enlarge



Picture showing the view added in the data source

Click to Enlarge


Add new screens




Picture showing adding the Editable Grid Screen in the project

Click to Enlarge



Picture showing the data source and screens added in the project

Click to Enlarge


Output




Picture showing the screen bound with table

Click to Enlarge

Picture showing the screen bound with view

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, November 28, 2012

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250