Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i get last id inserted in formview

Tags:

formview

i have a form view after inserting record i want to know the last id of inserted record

like image 600
Saeed Avatar asked Oct 15 '22 06:10

Saeed


1 Answers

You have to rely on your Datasource object. If you're using an EntityDataSource for instance, it's pretty easy. 1 Catch the event EntityDataSource1_Inserted(object sender, EntityDataSourceChangedEventArgs e) 2 There just Cast the entity that has been modified to your business entity. Let's say your entity is of type Persons. Then you should have in C# : var person = (Persons)(e.Entity); Of course, your entity does have a primary Key. Should it be ID, then you just call person.ID. That's it. Hope this helps, or at least, provides you with where you have to go next in solving your issue.

like image 192
MrKhal Avatar answered Oct 20 '22 18:10

MrKhal