?
Solved

Retrieve newly inserted object or ID using FormView with ObjectDatasource

Posted on 2013-01-29
3
Medium Priority
?
326 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month11 days, 7 hours left to enroll

752 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