我怎样才能获得插入到formview中的最后一个ID

发布于 2024-08-31 21:05:32 字数 35 浏览 8 评论 0原文

插入记录后我有一个表单视图我想知道插入记录的最后一个ID

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

汐鸠 2024-09-07 21:05:32

您必须依赖您的数据源对象。
例如,如果您使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文