DataBinder.ValidateControl

Event that can be hooked to validate each control after it's been unbound. Allows for doing application level validation of the data once it's been returned.

This method receives a DataBindingItem parameter which includes a reference to both the control and the DataSource object where you can check values. Return false from the event method to indicate that validation failed which causes a new BindingError to be created and added to the BindingErrors collection.

public event delItemResultNotification ValidateControl

Example

<<code lang="C#">>protected bool
DataBinder_ValidateControl(Westwind.Web.Controls.DataBindingItem Item)
{
    if (Item.ControlInstance == txtCategoryId)
    {
        DropDownList List = Item.ControlInstance as DropDownList;
        if (List.SelectedItem.Text == "Dairy Products")
        {
            Item.BindingErrorMessage = "Dairy Properties not allowed
(ValidateControl)";
            return false;
        }
    }

    return true;
}<</code>>

See also:

Class DataBinder

© West Wind Technologies, 1996-2016 • Updated: 12/12/15
Comment or report problem with topic