How to show delete confirmation in LightSwitch

If you want to ask user before deleting record then write the following code in your screen code editor.

Namespace LightSwitchApplication

    Public Class EditableCustomersGrid

        Private Sub gridDeleteSelected_Execute()
            ' Write your code here.
            If ShowMessageBox("Are you sure you want to delete this record?", "Confirm Delete", MessageBoxOption.YesNo) = MessageBoxResult.Yes Then
                Dim cust As Customer
                cust = Me.Customers.SelectedItem
                If Customers.CanDelete Then
                    cust.Delete()
                    Me.Save() '//Save immediately ..
                End If
            End If
        End Sub
    End Class

End Namespace

Binary World is a Software Development company located in Atlanta, USA (since 2007). Binary World specialized in Business Intelligence, mobile, cloud computing and .Net Application Development.

Tagged with: ,
Posted in .net, LightSwitch, VB.net

Leave a Reply