ComponentOne ADO.NET DataExtender
Working with C1DataViewSet / Row and Column Level Constraints / Defining Constraints
In This Topic
    Defining Constraints
    In This Topic

    You can define constraints using the Constraints tab located in the C1ViewSetDesignerForm. To define a constraint expression for the UnitPrice field of the Products table, perform the following tasks:

    1. Right-click the C1DataViewSet component and select Edit from its Tasks menu. The C1ViewSetDesignerForm appears.
    2. From the left pane, select the UnitPrice column of the Products table and click the Constraints tab.
    3. Select vb from the Language drop-down list to specify Visual Basic as the programming language used to define expression.
    4. Type the following expression in the Expression text box: Return newValue > 0

      OR

      Click the Expression Builder button to open the Expression Builder dialog box:


      Select the greater than operator and enter 0 for the Value. Click OK to close the dialog box.

    5. Type the following string in the Error Message box: UnitPrice must be a positive number
    6. Click OK to close the dialog box.

    If the user attempts to enter a negative number in the UnitPrice column of the Products grid, the following error message appears:


    Negative numbers are not allowed in accordance with the constraint we defined for the Products.UnitPrice field.

    See Also