locked
Check child datagrid contains rows on save RRS feed

  • Question

  • Hi

    I have a screen which contains a child datagrid.  The screen is used for entering order information and the child datagrid contains the items in the order. I would like to validate this screen so that it can't be saved unless there are items in the order ie. at least one row in the child datagrid.

    I have the validation almost working but it triggers the validation when the screen loads and displays the error that 1 validation issue exists which is correct but I would like it to trigger on save rather than load.

    Here is the code I am using:

    Private Sub OrderDetail_Validate(results As ScreenValidationResultsBuilder)
                If Me.OrderDetail.Count <= 0 Then
                    results.AddPropertyError("The order must contain items")
    
                End If
            End Sub

    If anyone can point me in the right direction I would be grateful.

    Many thanks

    Monday, July 14, 2014 6:57 PM