Get Record ID in Entity Framework after insert

前端 未结 4 1396
北荒
北荒 2021-02-07 02:34

I\'m developing an ASP.net application using Entity Framework. I\'m using DetailsView to insert data into database. There is a table as Client and its

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-07 03:09

    Thanks, I spent 3 days searching and searching with complicated results but this solution is brilliant! Here it is in vb.net:

    Protected Sub dvArticulos_ItemInserted(sender As Object, e As EntityDataSourceChangedEventArgs) Handles EntityDataSource1.Inserted
        Dim last_Serie As Long = DirectCast(e.Entity, articulos).Serie
        Session("Articulo") = last_Serie
    End Sub
    

提交回复
热议问题