Back to Devexpress

ASPxDiagram.NodeInserted Event

aspnet-devexpress-dot-web-dot-aspxdiagram-dot-aspxdiagram-a484bccd.md

latest4.6 KB
Original Source

ASPxDiagram.NodeInserted Event

Occurs after a node was inserted.

Namespace : DevExpress.Web.ASPxDiagram

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

NuGet Package : DevExpress.Web

Declaration

csharp
public event DiagramItemInsertedEventHandler NodeInserted
vb
Public Event NodeInserted As DiagramItemInsertedEventHandler

Event Data

The NodeInserted event's data class is DiagramItemInsertedEventArgs. The following properties provide information specific to this event:

PropertyDescription
AffectedRecordsGets the number of records affected by the update operation. Inherited from ASPxDataBaseUpdatedEventArgs.
ExceptionGets the exception (if any) that was raised during the update operation. Inherited from ASPxDataBaseUpdatedEventArgs.
ExceptionHandledGets or sets whether an exception raised during the update operation was handled in the event handler. Inherited from ASPxDataBaseUpdatedEventArgs.
KeyValueSpecifies the key value of the inserted item.
NewValuesGets a dictionary that contains the values of the non-key field name/value pairs in the row to be inserted. Inherited from ASPxDataInsertedEventArgs.

Remarks

aspx
<dx:ASPxDiagram ID="Diagram" runat="server" Width="100%" Height="600px" Units="In"
    NodeDataSourceID="FlowNodeDataSource" EdgeDataSourceID="FlowEdgeDataSource" 
    OnNodeInserted="Diagram_ItemInserted" OnEdgeInserted="Diagram_ItemInserted" >
    <SettingsAutoLayout Type="Layered" Orientation="Vertical" />
    <Mappings>
        <Node Key="ID" Type="Type" Width="Width" Height="Height" />
        <Edge Key="ID" FromKey="FromID" ToKey="ToID" Text="Text" />
    </Mappings>
</dx:ASPxDiagram>
<ef:EntityDataSource runat="server" ID="FlowNodeDataSource" ContextTypeName="DevExpress.Web.Demos.FlowContextSL" 
  EntitySetName="Nodes" EnableDelete="True" EnableInsert="True" EnableUpdate="True" OnInserted="FlowItemDataSource_Inserted">
</ef:EntityDataSource>
<ef:EntityDataSource runat="server" ID="FlowEdgeDataSource" ContextTypeName="DevExpress.Web.Demos.FlowContextSL" 
  EntitySetName="Edges" EnableDelete="True" EnableInsert="True" EnableUpdate="True" OnInserted="FlowItemDataSource_Inserted">
</ef:EntityDataSource>

Important

When you bind the ASPxDiagram control to a data source, ensure that the KeyValue property is specified.

cs
protected void FlowItemDataSource_Inserted(object sender, Microsoft.AspNet.EntityDataSource.EntityDataSourceChangedEventArgs e) {
    if (e.Entity is FlowEntity)
        lastInsertedId = ((FlowEntity)e.Entity).ID;
}

protected void Diagram_ItemInserted(object sender, DevExpress.Web.ASPxDiagram.DiagramItemInsertedEventArgs e) {
    e.KeyValue = lastInsertedId;
}
vb
Protected Sub FlowItemDataSource_Inserted(ByVal sender As Object, ByVal e As Microsoft.AspNet.EntityDataSource.EntityDataSourceChangedEventArgs)
    If TypeOf e.Entity Is FlowEntity Then lastInsertedId = (CType(e.Entity, FlowEntity)).ID
End Sub

Protected Sub Diagram_ItemInserted(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxDiagram.DiagramItemInsertedEventArgs)
    e.KeyValue = lastInsertedId
End Sub

Run Demo: Node and Edge Data Sources

See Also

ASPxDiagram Class

ASPxDiagram Members

DevExpress.Web.ASPxDiagram Namespace