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.
Step 2
In the Solution Explorer, right-click on the Data Source and choose "Add Table".
Step 3
The table appears.
Step 4
In the Solution Explorer, right-click on the Screens and choose "Add Screen".
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".
Step 6
The Editable Employee Grid Designer (Blank Designer) appears.
Step 7
In the Menu bar click on "Add Data Item".
Step 8
The Add Data Item Dialog box appears.
Step 9
Select "Local Property" from the Add Data Item.
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".
Step 11
From the "Write Code" option, select the InitializeDataWorkspace method and do some coding as shown.
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.
Step 13
The Property Window appears.
Step 14
In the Property Window change the Control Type to "TextBox" and set the Label Position to "collapsed".
Press F5 to run the application.