开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜