Adding Records at Run Time in Visual Studio LightSwitch 2012

This article shows how to add more records at run time in a LightSwitch application using Visual Studio 2012.

The following is the procedure for adding more records at run time

Step 1

Open the Solution Explorer.

solu explo.jpg

Step 2

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

Add table.jpg

Step 3

The table appears.

table.jpg

Step 4

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

add screen.jpg

Step 5

Select "New Data Screen" from the Screen Templates. Under Screen Information we provide the Screen Name and select any Screen Data and then click "OK".

add new screen.jpg

Step 6

The CreateNewEmpTable Screen Designer appears.

app desi.jpg

Step 7

Press F5 in to run the application.

empty output.jpg

Enter the data in the following Textboxes. Click on the Save button to store the data.

output.jpg

Step 8

If we want to add more records then close the current tab and click on "Tasks" and again click on "Create New Emp Table" in the Menu Bar.

create new emp table.jpg

Again provide the data in the following textboxes and click on the "Close" button without saving it.

output2.jpg

Step 9

The Unsaved changes dialog box appear on the screen.

unsaved changes.jpg

Click on the "Save" button to save the unsaved records to the database. Click on the "Discard" button if you don't want to save the records. Click on the "Cancel" button to stay on the same page.

Step 10

We can also change the Name of the screen by changing the Name in the Display Screen property window and we will see it by running the application.

new property.jpg

As we run the application we get:

app.jpg


Similar Articles