Thursday, 19 July 2012

Lightswitch: Get multi-selected items from DataGrid

This allows you to access all the selected items in the grid instead of just one (the SelectedItem property)
private const string Grid = "gridname";
private DataGrid _gridControl = null;
partial void Screen_InitializeDataWorkspace(List<IDataService> saveChangesTo)
this.FindControl(Grid).ControlAvailable +=
new EventHandler<ControlAvailableEventArgs

void Grid_ControlAvailable(object sender, ControlAvailableEventArgs e)
_gridControl = e.Control
as DataGrid

if (_gridControl != null
_gridControl .SelectionMode =
partial void SomeAction_Execute()
foreach (ObjectName e in
_gridControl.SelectedItems)     {         ...   


Lightswitch: Get choice value of a property

I have found quite a number of things from the internet when I was doing my Lightswitch development, but I cannot remember most of the source now. So thanks for people in the community who have contributed but sorry I cannot acknowledge them properly.


Here is an extension method for getting the choice value of a property in code:

public static string GetDisplayedChoiceValue(this IEntityStorageProperty property)
// If the value is null, it has no display value
if (null == property.Value)
return null;

string valueAsString = property.Value.ToString();
// Get the list of choices for this property
IEnumerable<ISupportedValueAttribute> choices = property.
// Find the choice that matches the property value
ISupportedValueAttribute choice = choices.Single(
c => String.Equals(c.Value, valueAsString, StringComparison.Ordinal));

// If the choice does not have a display name, return the choice value instead
if (String.IsNullOrEmpty(choice.DisplayName))
return choice.Value;
return choice.DisplayName;

To use it with your object:

CodeName = o.Details.Properties.Code.GetDisplayedChoiceValue(),

Wednesday, 29 February 2012

Job Ad.

Actually, not just Graduate Software Developers we are looking for, but Intermediate, Senior… whoever interested…