Back to Devexpress

TreeListNodeValidationEventArgs Class

aspnet-devexpress-dot-web-dot-aspxtreelist-999cd736.md

latest3.2 KB
Original Source

TreeListNodeValidationEventArgs Class

Provides data for the ASPxTreeList.NodeValidating event.

Namespace : DevExpress.Web.ASPxTreeList

Assembly : DevExpress.Web.ASPxTreeList.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public class TreeListNodeValidationEventArgs :
    EventArgs
vb
Public Class TreeListNodeValidationEventArgs
    Inherits EventArgs

TreeListNodeValidationEventArgs is the data class for the following events:

Example

This example demonstrates how to check the validity of data entered by end-users into a node. Validation is implemented within the ASPxTreeList.NodeValidating event handler. In this sample, validation fails in the cases listed below:

  • the department isn’t specified;
  • the budget is negative.

The image below shows the result:

aspx
<dx:ASPxTreeList ID="ASPxTreeList1" runat="server" AutoGenerateColumns="False"
    DataSourceID="AccessDataSource1"
    KeyFieldName="ID" ParentFieldName="ParentID" OnNodeValidating="ASPxTreeList1_NodeValidating">
    <Columns>
        <dx:TreeListTextColumn FieldName="Department" VisibleIndex="0">
        </dx:TreeListTextColumn>
        <dx:TreeListTextColumn FieldName="Budget" VisibleIndex="1">
        </dx:TreeListTextColumn>
        <dx:TreeListTextColumn FieldName="Location" VisibleIndex="2">
        </dx:TreeListTextColumn>
        <dx:TreeListTextColumn FieldName="Phone" VisibleIndex="3">
        </dx:TreeListTextColumn>
        <dx:TreeListCommandColumn VisibleIndex="4">
            <EditButton Visible="True">
            </EditButton>
        </dx:TreeListCommandColumn>
    </Columns>
</dx:ASPxTreeList>
csharp
protected void ASPxTreeList1_NodeValidating(object sender, TreeListNodeValidationEventArgs e) {
    if ((int)e.NewValues["Budget"] < 0)
        e.Errors["Budget"] = "Negative values aren't allowed";
    if (e.NewValues["Department"] == null)
        e.Errors["Department"] = "Required field";
    if (e.Errors.Count != 0)
        e.NodeError = "Node update failed. Please check node values.";
}

Inheritance

Object EventArgs TreeListNodeValidationEventArgs

See Also

TreeListNodeValidationEventArgs Members

Node Validation and Error Indication

DevExpress.Web.ASPxTreeList Namespace