cnd
cnd

Reputation: 33714

ASP.NET [Object data source]

I send id of my class object from one page to second this way :

NavigateUrl='<%# "ItemDetail.aspx?itemId=" + (string)Eval("Id") %>'

Then I get the object with ObjectDataSource and function this way :

<asp:ObjectDataSource ID="ObjectDataSourceItem" runat="server" SelectMethod="GetItem"
            TypeName="Catalog">
            <SelectParameters>
                <asp:QueryStringParameter Name="itemId" QueryStringField="itemId" Type="string" DefaultValue="" />
            </SelectParameters>
        </asp:ObjectDataSource>

So how to use this item in my new page code :

this.ObjectDataSourceItem.?????

Upvotes: 0

Views: 1044

Answers (1)

Jamie Ide
Jamie Ide

Reputation: 49251

You need to subscribe to the ObjectDataSource's Selected event, access the ObjectDataSourceStatusEventArgs ReturnValue property (e.ReturnValue), and cast it to the appropriate type. Something like:

protected void ObjectDataSourceItem_Selected(object source, ObjectDataSourceStatusEventArgs e)
{
    var myDataSet = (DataSet)e.ReturnValue;
}

Upvotes: 1

Related Questions