Articles → Light Switch 2011 → Default Value In Light Switch 2011

Default Value In Light Switch 2011






Software Requirement




  1. Visual studio 2010 is installed on your machine.
  2. Visual Studio 2010 service pack 1 is installed on your machine.
  3. Microsoft Visual Studio Light switch 2011 is installed on your machine.

Prerequisite Knowledge




  1. What is lightswitch?
  2. What are screens and entities in lightswitch?
  3. How to create an entity in lightswitch?
  4. How to create a screen in lightswitch?
  5. How to work on screen designer in lightswitch application?

Why Default Value Is Required





Creation Of Sample Entity




Picture showing the CreatedOn field with Display by Default checkbox unchecked

Click to Enlarge






Add Default Value




Picture showing invoked the Employee_Created event for the entity

Click to Enlarge



Picture showing setting the default value of the field in the Employee_Created event in code behind

Click to Enlarge




Creation Of New Data Screen




  1. Right click on the Screens folder and click Add Screen… option.
  2. When you click on it a new screen open up.
  3. Select New Data Screen as screen type.
  4. Enter Screen Name.
  5. Select Screen Data.
  6. Uncheck Employee Details checkbox.
  7. Click Ok.
  8. A new screen will be added to the solution.
  9. Picture showing adding the new screen in the lightswitch application

    Click to Enlarge



Designer View Of New Data Screen




Picture showing th designer window of the new screen in lightswitch

Click to Enlarge




Creation Of Search Data Screen




  1. Right click on the Screens folder and click Add Screen… option.
  2. When you click on it a new screen open up.
  3. Select Search Data Screen as screen type.
  4. Enter Screen Name.
  5. Select Screen Data.
  6. Click Ok.
  7. A new screen will be added to the solution.
  8. Picture showing the add screen popup for adding the search screen

    Click to Enlarge



Designer View Of Search Data Screen




Picture showing adding the CreatedOn field dropped on the designer window

Click to Enlarge


Add New Data


  1. Run the program
  2. Enter the details.
  3. Click Save.
  4. Data is entered into the table.
Picture showing the Save button for saving the record

Click to Enlarge




Search Screen




Picture showing the CreatedOn field on the grid with the default value

Click to Enlarge




Conclusion





Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, January 24, 2012

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250