Binding Grid From Query in LightSwitch 2012 - Part 2

In my previous article I described how to add a query on the table in LightSwitch using Visual Studio 2012. (http://www.c-sharpcorner.com/UploadFile/18ddf7/binding-grid-from-query-in-lightswitch-2012-part-1/)

This article describes how to bind a grid with a query in LightSwitch 2012.

The following is the procedure of binding a grid with a query.

Step 1

Now first of all we are going to add another Editable Grid Screen. Select Query under Screen Data in the Add New Screen dialog box then click the OK button.

src1.jpg

Step 2

The Screen Designer appears and we will see that the optional parameter will be present at the top in the Screen Designer.

src desi1.jpg

Step 3

Press F5 to run the application. We will notice that all the data is available if the optional parameter is empty.

out1.jpg

Once we provide the value in the optional parameter, all the data related to that parameter will be populated.

output acc to address.jpg

Step 4

Now stop debugging and to bind a drop down with a query go to the menu bar and click on Add Data Item.

Add Data Item.jpg

The Add Data Item dialog box appears on the screen. From that choose Local Property and provide some name to the data item and click the OK button.

Add data item dialog.jpg

After the data item is added, drag it onto the screen.

drag emp.jpg

Step 5

The next step is to add a query. Once again click on Add Data Item. The Add Data Item dialog box will appear. Choose Query and click the OK button.

Query add data item.jpg

The query will be added as in the following

src desi3.jpg

Once the query has been added click on Add Data Item (Emp). Then press F4. The property window appears. Select the "New Query1" from the Choices option in the property window.

choices prop.jpg

Step 6

Press F5 to run the application. We will see a drop down list in the output.

drop down.jpg

Up Next
    Ebook Download
    View all
    Learn
    View all