Solved

Retrieve newly inserted object or ID using FormView with ObjectDatasource

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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