Web and Business Objects...how to tie them together

Discussion in 'ASP .Net Web Controls' started by Relaxin, Apr 16, 2007.

  1. Relaxin

    Relaxin Guest

    I have created my own business objects with both a Collection class and a
    record class.

    When I use the ObjectDataSource (ODS) it requires a SelectMethod from the
    Collection class.
    My first try I made this a static function within my collection class, but
    the ODS_ObjectCreated event won't fire. (very strange design)
    So I changed it to a regular class function, where the class has to be
    instantiated in order to be use it. (I don't get this...why the need to
    instantiate a class to call a function within that class to instantiate the
    SAME class again!!....again, a very strange design).

    Back to my issue...

    All I have on my web form is a gridview and an ODS.

    I created my collection and stored it in a session variable.

    [1] if(!IsPostBack)
    {
    if(Session["Receipt"] == null)
    {
    m_ReceiptCollection = new ReceiptLinesCollection();
    Session["Receipt"] = m_ReceiptCollection;
    }
    m_ReceiptCollection =
    (ReceiptLinesCollection)Session["Receipt"];
    }

    I reuse this object for the ODS to use.
    [2] protected void ObjectDataSource1_ObjectCreated(object sender,
    ObjectDataSourceEventArgs e)
    {
    m_ReceiptCollection = (ReceiptLinesCollection)Session["Receipt"];
    e.ObjectInstance = m_ReceiptCollection;
    }

    The creation of my Business Object(BO) causes 2 records to be loaded into
    it.

    When I load the web page my Postback code is ran and my collection is
    created as you can see above[1].
    And thru debugging I see that my BO is created again for the ODS to
    use...but I'm assigning it the object that I want it to use...see above[2].
    *1* I can't find any other way to assign the ODS a preallocated BO to use,
    the only way is thru the ObjectCreated event.

    When I click the "Edit" link on the grid, it once again creates another BO!

    Then I edit one of the fields and then click "Update". It creates another BO
    to call the UpdateMethod to send me a collection record.

    *2* This is what I don't get, the ODS has the collection list [2], but it
    won't update the record in the list, but instead sends me a brand new record
    for me to place in the list. But guess what, the UpdateMethod doesn't know
    what list to update because all it has is an orphaned record with no parent
    (Collection).

    Can someone PLEASE help me to understand this convoluted design with issues
    *1* and *2*?

    Thanks
     
    Relaxin, Apr 16, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. agent349
    Replies:
    12
    Views:
    476
    Mark A. Gibbs
    Apr 18, 2004
  2. Anonieko

    HttpHandlers - Learn Them. Use Them.

    Anonieko, Jun 15, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    521
    tdavisjr
    Jun 16, 2006
  3. Rowan

    How to put them together

    Rowan, Jun 27, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    320
    bruce barker
    Jun 27, 2007
  4. CBlair1986
    Replies:
    4
    Views:
    135
    CBlair1986
    Nov 18, 2006
  5. botfood

    tie() with DB_File not tie()ing ?

    botfood, Apr 24, 2006, in forum: Perl Misc
    Replies:
    23
    Views:
    458
    botfood
    Apr 26, 2006
Loading...

Share This Page