Retrieving the value of the identity field of a newly inserted record?

C

Craig

In ASP.NET 2.0 and the formview control how do you get the value of the
identity field of a newly inserted record?

In ASP.NET 1.1 after the new record was saved you just said
intNewIdentityID = Dataset.tblMtTable.IndentityID
Simple but can't seem to do it in the formview.



Thanks
 
G

Guest

You need to create an event handler for the DataSource Control that the
FormView Control is bound to. In the Properties for the DataSource Control,
view the Events (Lightning Bolt) and double click on the "Inserted" event.
This will create the handler.

This event is raised when a record is inserted. Within the handler add...

int Id = e.Command.Parameters["@WhatYouNamedReturnParam"].Value

This will grab the Id value of the inserted record as long as you set it up
in the stored procedure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top