我怎样才能获得插入到formview中的最后一个ID
插入记录后我有一个表单视图我想知道插入记录的最后一个ID
i have a form view after inserting record i want to know the last id of inserted record
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须依赖您的数据源对象。
例如,如果您使用 EntityDataSource,则非常简单。
1
赶上活动
EntityDataSource1_Inserted(对象发送者,EntityDataSourceChangedEventArgs e)
2
那里只是将已修改的实体投射到您的业务实体。
假设您的实体属于 Persons 类型。那么你应该在 C# 中:
var person = (Persons)(e.Entity);
当然,您的实体确实有主键。如果是ID的话你就直接打电话
人员 ID。
就是这样。
希望这会有所帮助,或者至少为您提供下一步解决问题的方法
问题。
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.