Solved

Retrieve newly inserted object or ID using FormView with ObjectDatasource

Posted on 2013-01-29
3
324 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 500 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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