Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Retrieve newly inserted object or ID using FormView with ObjectDatasource

Posted on 2013-01-29
3
Medium Priority
?
337 Views
Last Modified: 2013-03-15
I created a formview that uses an ObjectDataSource. After the insert is done I need to to retrieve the ID. I know how to do this using SQLDataSource but am not sure if it is possible using ObjectDataSource.
0
Comment
Question by:dmoss123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 38832776
0
 

Author Comment

by:dmoss123
ID: 38832962
Using SQLDataSource, the output parameter (of the datasource) retrieves the ID using the return value of the stored procedure. I'm not sure how I would duplicate that with ObjectDataSource as the ObjectDataSource calls a method not a stored procedure.
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 2000 total points
ID: 38832987
Return the value from your method and then get it as e.ReturnValue

protected void ObjectDataSource1_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
    {
        e.ReturnValue // it's an object
    }

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question