473,322 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

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
Jan 2 '06 #1
1 1578
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.

"Craig" wrote:
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

Jan 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware ...
4
by: olafmol | last post by:
Hello, i am wondering if there is a simple way to insert a new record into an MS Access db and read out the newly created auto-ID field. Using ASP this was rather simple, but in ASP.NET (VB) it...
1
by: Craig | last post by:
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 =...
8
by: Doru Roman | last post by:
Hi, I insert a new record with a command: private SqlCommand comInsert; comInsert = conDataBase.CreateCommand(); comInsert.CommandType = CommandType.Text;
17
by: Rico | last post by:
Hello, I am in the midst of converting an Access back end to SQL Server Express. The front end program (converted to Access 2003) uses DAO throughout. In Access, when I use recordset.AddNew I...
3
by: Susanne Klemm | last post by:
Hello! I use a procedure to insert a new row into a table with an identity column. The procedure has an output parameter which gives me the inserted identity value. This worked well for a long...
8
by: Dave | last post by:
I have a form with a label that should show an invoice number. The invoice number should be generated by sql Server using an autoincremented technique. However, after reading several articles, it...
4
by: Mark Olbert | last post by:
I am struggling with trying to retrieve the value of an autoincrement identity field after a DetailsView Insert operation. The DetailsView is bound to an SqlDataSource control. So far as I can...
15
by: gunnar.sigurjonsson | last post by:
I´m having some problem retrieving identity value from my newly inserted row into a view. I have two tables T1 and T2 which I define as following CREATE TABLE T1 ( id BIGINT GENERATED ALWAYS...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.