Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6079869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:59:44+00:00 2026-05-23T10:59:44+00:00

net and C# 4. I have a DetailsView Control , and I use some

  • 0

net and C# 4.

I have a DetailsView Control, and I use some custom logic for data binding.

When input data in my DetailsView I would like to use the Event "Inserted" (or another) to get from the DetailsView the Primary Key for the recently inserted data (I suppose using the DataKey properties).

Unfortunately I’m not able to do it.

Do you have any idea how to insert retrive the Primary Key for a item being inserted using the DetailsView?

Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:59:44+00:00Added an answer on May 23, 2026 at 10:59 am

    First of all, your SQL statement needs to return the SCOPE_IDENTITY().

    Second, assuming you are using an ObjectDataSource control, get e.ReturnValue in your datasource control’s Inserted event, as in the following example:

    protected void dsReferralInsert_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
    {
        int intKey;
        if (int.TryParse(e.ReturnValue, out intKey))
        {
            Response.Redirect("ReferralDetail.aspx?ReferralID=" + intKey.ToString());
        }
    }
    

    This example uses the new key value to redirect to the detail page.

    If you are using a SqlDataSource control, you can programmatically access either Output parameters or ReturnValue parameters, depending on how you wrote the SQL. I’ll make an example if you fill me in on what kind of data access you are using.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a DetailsView in ASP.NET that gets data from the database based
Say you have something like an ASP.NET ASP:DetailsView to show and edit a single
I have a ASP.NET code, I use it to insert and view my data
I have a asp.net detailsview control on a page. I've noticed that it always
Does .NET have some type of built in function that allows filtering on Gridviews?
Does .Net have any built in constants for common numbers like million, billion etc?
Does dot net have an interface like IEnumerable with a count property? I know
.NET we have primitive datatypes like int and value types like struct. And also
I have details view control in my asp.net web form, which on of its
Am using VS2008 ASP.Net Web Forms have a detailsview, databound to web service reference

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.