All docs
V20.2
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

DiagramItemInsertedEventArgs.KeyValue Property

Specifies the key value of the inserted item.

Namespace: DevExpress.Web.ASPxDiagram

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

Declaration

public object KeyValue { get; set; }
Public Property KeyValue As Object

Property Value

Type Description
Object

An object that uniquely identifies the item.

Remarks

The ASPxDiagram control builds a diagram based on the nodes' and edges' key values.

When the control binds to a data source, the source assigns the keys for inserted items. The control send a request to the server side to get the assigned keys. In some cases the control can figure out the keys (for instance, for an SQLDataSource or ObjectDataSource objects).

If the ASPxDiagram control can not determine the keys (for instance, for an EntityDataSource object), specify the KeyValue in the EdgeInserted and NodeInserted events.

NOTE

If an item's key is not determined, the "The inserted item key is undefined. Use the DiagramItemInsertedEventArgs.KeyValue property to specify the key value for a newly inserted {0}" exception is thrown.

<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>
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;
}
See Also