tisdag 21 september 2010

LightSwitch - Creating the Data

So, to create a table for your data you can either click the "Create new table" link on the startpage or you can right click the "Data Sources" folder in the solution explorer and choose "Add Table".

The next step is to rename your table, either in the designerarea by clicking its name or in the "properties" view. With that out of the way, start designing your table. You wil lnotice that you got the "id" column by default, but the rest is up to you. Since I plan to put administrators in there, I choose to add FirstName, LastName, Email and Phone in mine.

The "Type" field needs some extra care. This field wil give your Screen the suitable component, like a datepicker control for a "date" field, but will also provide basic validation, so give it an extra thought when designing your table. I have strings for my name fields, but an "EmailAdress" type for my Email and "PhoneNumber" for my phone.

With the table ready, we will just need a simple screen for editing its data. Right click on the "Screen" folder in the Solution Explorer and choose "Add Screen". The "New Screen Dialog" will present you with the available templates. Choose "Editable Grid", change its name and pick your table as the source in the "Screen Data" dropdown list.


And that's it, you should be able to run your basic application by hitting "F5" inside Visual Studio. Try to add some data in the Grid and make sure the validation works

Inga kommentarer:

Skicka en kommentar