Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 17th, 2008, 06:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default Get sproc return value from ObjectDataSource

Hi folks,

I have a SqlDataSource object with the folloiwng parameters:

Code:
<SelectParameters>
         <asp:ControlParameter Name="pageNum" ControlID="pn1" PropertyName="SelectedPage" />
         <asp:Parameter DefaultValue="10" Name="pageSize" Type="Int32" />
         <asp:Parameter Name="pageCount" Direction="ReturnValue" Type="Int32" />
</SelectParameters>
I can access the return value parameter in code with:

Code:
protected void SqlDataSource1_Selected(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
    {
        int pages;
        pages = (int)e.Command.Parameters["@pageCount"].Value;
        pn1.Count = pages;
        Pn2.Count = pages;
    }


I'm re-writing the app using business objects and ObjectDataSource controls. The ObjectDataSourceStatusEventArgs doesn't have a Command.Parameters collection. How do you access an ObjectDataSource return parameter when you business methods execute stored procedures that return values?

ObjectDataSourceStatusEventArgs has a ReturnValue property, but it references the return value of the business method (in my case a collection), not the return value of the stored procedure executed by the business method.

Any thoughts much appreciated.

Bob

 
Old January 17th, 2008, 07:01 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Bob,

You could create a property on the collection and update in from within the code that talks to the stored procedure.
The ObjectDataSource shouldn't know about implementation. E.g. it shouldn't have to understand whether underlying code calls a stored procedure, an XML file or just makes something up itself. Therefore you need to solve this through the business objects themselves.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old January 17th, 2008, 07:57 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Thanks Imar. That makes sense.

Bob



 
Old January 19th, 2008, 10:22 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

This problem resolved at:

http://p2p.wrox.com/topic.asp?TOPIC_ID=68430

Apologies for posting versions of it all over town. :)

Bob






Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with sproc Bob Bedell SQL Server 2005 10 January 20th, 2008 08:52 AM
dynamic sproc sabry SQL Language 1 August 25th, 2006 06:23 AM
When a sproc or table was Last Used dlandolin SQL Server 2000 1 September 29th, 2005 08:09 PM
Working with Dates in SPROC [email protected] SQL Language 4 March 10th, 2004 03:56 PM
looping through return records in sproc jtyson SQL Server ASP 5 July 14th, 2003 10:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.