Display Data on the Blank Screen in LightSwitch Using Visual Studio 2012

This article describes how to display data on a blank screen in LightSwitch using Visual Studio 2012.

Procedure for displaying data on a blank screen in LightSwitch using Visual Studio 2012

Step 1

Open the Solution Explorer.

sol explo (2).jpg

Step 2

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

add table (2).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 (2).jpg

Step 5

Select the EditableGrid Screen from the Screen Template. Under Screen Information we provide the Screen Name but do not select any Screen Data and then click "OK".

add sr.jpg

Step 6

The Editable Employee Grid Designer (Blank Designer) appears.

blank designer.jpg

Step 7

In the Menu bar click on "Add Data Item".

add data item.jpg

Step 8

The Add Data Item Dialog box appears.

add data item1.jpg

Step 9

Select "Local Property" from the Add Data Item.

property.jpg

Step 10

Under Local Property select the type and check the checkbox on the basis whether the Type Is Required or not and provide a name for it. Here I provided the name "My TextBox".

property.jpg

Step 11

From the "Write Code" option, select the InitializeDataWorkspace method and do some coding as shown.

writecode.jpg

using System;

using System.Linq;

using System.IO;

using System.IO.IsolatedStorage;

using System.Collections.Generic;

using Microsoft.LightSwitch;

using Microsoft.LightSwitch.Framework.Client;

using Microsoft.LightSwitch.Presentation;

using Microsoft.LightSwitch.Presentation.Extensions;

namespace LightSwitchApplication

{

    public partial class EditableGrid

    {

        partial void EditableGrid_InitializeDataWorkspace(List<IDataService> saveChangesTo)

        {

            // Write your code here.

            this.MyTextBox = "String Type Text";

 

        }

    }

}

Step 12

Now drag the My TextBox Property onto your screen where ever you want.

drag to screen layout.jpg

Step 13

The Property Window appears.

default prop.jpg

Step 14

In the Property Window change the Control Type to "TextBox" and set the Label Position to "collapsed".

setting prop.jpg 

Press F5 to run the application.

output adding text.jpg

Up Next
    Ebook Download
    View all
    Learn
    View all