View Single Post
Old January 17th, 2008, 06:15 PM
Bob Bedell Bob Bedell is offline
Friend of Wrox
Join Date: Jun 2003
Location: , , USA.
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:

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

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.