开发者

Is it possible to get the Identity value in the ItemInserted event in a listView?

开发者 https://www.devze.com 2022-12-24 12:45 出处:网络
I\'d rather not make a call to the database to query @@IDENTITY.Is there some way to get the identit开发者_运维技巧y value for what was just inserted through code?Found a solution by adding an OnInser

I'd rather not make a call to the database to query @@IDENTITY. Is there some way to get the identit开发者_运维技巧y value for what was just inserted through code?


Found a solution by adding an OnInserted event to my LinqDataSource that my listview was using. See below:

protected void lds_Personnel_OnInserted(object sender, LinqDataSourceStatusEventArgs e)
{
    int id= ((Personnel)e.Result).IdentityNameHere;
.
.
.
}

Hope it's helpful to someone.


Try using SCOPE_IDENTITY() instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消