Error Message Customization

Custom Error Message on Adding Record

This customization shows how to enable and use a CustomValidator for a column of a row in an editable table.
Record Control Class
Select the record control class where this customization will be added
Table Name
Select a table to add new record
Primary Key
Select the primary key in the table
Primary Key Control
Select the primary key control
Applies to
RecordControl class
/// Override Validate method. If record exists, do not add the record and throw
/// custom error message to the user.
/// When an exception is thrown in the Validate() method, it is caught in the SaveButton_Click event handler.
/// SaveButton_Click event handler calls RegisterJScriptAlert to report the error message to the user.
/// Throwing an exception ensures that the record will not be saved. If the exception is
/// not thrown the record is saved.
public override void Validate() 

    //  Create a whereStr 
    string whereStr = ${${Table Name}ClassName}.${Primary Key}.InternalName + "='" + this.${Primary Key Control}.Text + "'";       
    ${${Table Name}RecordClassName} rec = null;

    // Check if the record exists
    rec = ${${Table Name}ClassName}.GetRecord(whereStr);

    // If record exists then throw custom error message to the user
    if (!(rec == null))
        // Set custom error message
        throw new Exception("Record with this primary key already exists.");


Terms of Service Privacy Statement