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

Discussion in 'ASP .Net' started by Craig, Jan 2, 2006.

  1. Craig

    Craig Guest

    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
     
    Craig, Jan 2, 2006
    #1
    1. Advertising

  2. RE: Retrieving the value of the identity field of a newly inserted rec

    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
    >
    >
    >
     
    =?Utf-8?B?SmFtZXM=?=, Jan 25, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick.O.Ige
    Replies:
    0
    Views:
    533
    Patrick.O.Ige
    Oct 31, 2007
  2. fig000
    Replies:
    0
    Views:
    631
    fig000
    Sep 6, 2008
  3. Craig
    Replies:
    0
    Views:
    145
    Craig
    Jan 2, 2006
  4. Replies:
    0
    Views:
    222
  5. 11D.Universe

    Retrieve newly inserted record ID?

    11D.Universe, Jun 11, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    175
Loading...

Share This Page