Sorting Data in LightSwitch 2012

This article shows how to sort data in a LightSwitch Application (Visual C#) in Visual Studio 2012.

The following is the procedure for sorting data in LightSwitch.

Step 1

Open the Solution Explorer.

sol ex.jpg

Step 2

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

add tab.jpg

Step 3

The table appears.

Emp table.jpg

Step 4

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

Add Src.jpg

Step 5

The Add New Screen dialog box appears. Select the "Editable Grid Screen" from the Screen Template, under screen information, choose "Employee" under screen data and provide a name to the Screen and click the "OK" button.

Add New Src.jpg

Step 6

The Screen Designer appears.

app designer.jpg

Step 7

In the screen designer, click on the "Edit Query" link as in the following.

Edit link.jpg

Step 8

The Screen will appear. In the "Sort" row.


The row contains a drop down list with the set of the following fields.

drop down.jpg

From the following list you can select any field on which you want to apply the sorting. You can sort the fields in any order, either in ascending or descending order.

Step 9

You can sort on more than one column as in the following.

add new.jpg

Adding New Sort on other field:

then by.jpg

Step 10

The Add Sort button will be disabled when the number of rows becomes equal to the number of columns in the table.

add sort disable.jpg

Step 11

There is a red colored cross button in the beginning of each row. By clicking on that button you can delete that particular row.


Step 12

Press F5 to run the application.


Similar Articles