Adding New Records Using Editable DataGrid Screen in LightSwitch 2012

This article shows how to add a new record using an Editable Datagrid Screen in a LightSwitch application using Visual Studio 2012.

I am using the table I created in my previous article (http://www.c-sharpcorner.com/UploadFile/18ddf7/customizing-search-screen-in-lightswitch-2012/),

The following is the procedure for adding a new record in the Editable DataGrid Screen.

Step 1

Open the Table (EmpTable) from the Solution Explorer.

table.jpg

Step 2

Click on the Screen Button from the Menu bar to add the screen.

screen add.jpg

Step 3

Since we are creating an Editable DataGrid Screen, choose the "Editable DataGrid Screen" template. Under Screen Information we provide the Screen Name and select any Screen Data and then click OK.

editable grid src.jpg

Step 4

Once you click the "OK" button, the screen designer appears inside the Visual Studio IDE.

src designer.jpg

Step 5

Press F5 to run the application.

Running Employee table appears.jpg

Step 6

Click on the Tasks option in the menu and choose the Editable Emp Tables Grid.

Editable employee select.jpg

Step 7

This will open the "Editable Emp Tables Grid" screen as a new Tab. In the same screen you will see a "Save" and "Refresh" button, a "Search Panel" and a button called "Export to Excel". It also consists of "Add", "Edit" and "Delete" buttons.

editable emp table grid.jpg

Add a New Record

There are two ways to add a record.

Step 8

The first way is to click on an empty row. That it will create a new row in the DataGrid.

double click to add.jpg

Step 9

Enter the record in the particular row and click on the Save button.

record added.jpg

Step 10

The second way is to click on the Add (+) Button provided in the screen as in the following:

+ button.jpg

Step 11

The "Add New Emp Table" child window appears. Enter the records in the window and click the "OK" button.

add dialog box.jpg

You will see that the record has been inserted successfully in the Editable Emp Tables Grid.

table after add.jpg

I will explain "How to Edit and Delete a record from an Editable Emp Tables Grid" in my future article.

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now