如何使用 LinqDataSource 获取 ASP.NET DetailsView 中插入记录的新 ID
如果我通过覆盖 Insert 语句并使用 @@IDENTITY 属性来使用 SqlDataSource,我就得到了答案,但是当我使用 LinqDataSource 时,我无法覆盖 Insert 语句!
所以,问题是:
我正在使用 ASP.NET Webform、插入模式下的 DetailsViewControl 和 LinqDataSource。
我想检索插入记录的新 ID。最简单、最有效的方法是什么?
谢谢。
I've got the answer if I were using SqlDataSource by Overriding the Insert Statement and use the @@IDENTITY property, but when I use the LinqDataSource, I couldn't override the Insert statement!
so, the problem is:
I'm using ASP.NET Webform, DetailsViewControl in Insert Mode and LinqDataSource.
I want to retrieve the new ID of the inserted record. What's the easiest and the most efficient way to do that?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 LinqDataSource.Inserted 事件
MSDN 中的示例显示 newProduct.ProductID 是新 ID。
Using LinqDataSource.Inserted Event
Example from MSDN shows that newProduct.ProductID is the new ID.