Subject: Problem Extending ObjectDataSource and ObjectDataSourceVi

Discussion in 'ASP .Net Building Controls' started by eacsub, Feb 8, 2006.

  1. eacsub

    eacsub Guest

    I have an extended version for both those classes. MyObjectDataSource
    overrides the GetView(string) method to return the custum view. The problem
    that the my costom view doesn't get it's properties intialized like the
    "SelectMethod", "DeleteMethod". they all appear as empy strings. However the
    base implementation get's those properties set right.

    The only reason i'm overloading the ObjectDataSourceView is that i want to
    implement my own Delete method by overriding the ExecuteDelete().

    Is there a way to make this work?

    Thanks in advance.
    eacsub, Feb 8, 2006
    #1
    1. Advertising

  2. eacsub

    Darren Clark Guest

    "eacsub" wrote:

    > I have an extended version for both those classes. MyObjectDataSource
    > overrides the GetView(string) method to return the custum view. The problem
    > that the my costom view doesn't get it's properties intialized like the
    > "SelectMethod", "DeleteMethod". they all appear as empy strings. However the
    > base implementation get's those properties set right.
    >
    > The only reason i'm overloading the ObjectDataSourceView is that i want to
    > implement my own Delete method by overriding the ExecuteDelete().
    >
    > Is there a way to make this work?
    >
    > Thanks in advance.


    I had a similar problem. The issue is really in the design of the
    ObjectDataSource class. It is not well planned for inheritance.

    Specifically...

    The ObjectDataSource class has a private method GetView, which return the
    contents of a private variable _view, creating a new ObjectDataSourceView if
    necessary. The ObjectDataSource implementation of the virtual GetView(String)
    method calls this private method. So far so good.

    Unfortunately, everywhere else in the class also calls this private method,
    not the virtual GetView(String) making the class nearly impossible to inherit
    from. What will happen if you override GetView(String) yourself, is that
    objects using your data source as a DataSourceControl or IDataSource will get
    your view, but all calls to methods such as Select, etc will be passed onto
    ANOTHER view created by the ObjectDataSource.

    There are two ways around this...

    1. In your GetView(String) method use reflection to find the private _view
    variable and set it with your new view.
    2. Inherit from DataSourceControl and implement your own data source.

    Option 1 actually works pretty well, but isn't the cleanest approach. In my
    case I found that it wasn't all that hard to implement a class directly
    inheriting from DataSourceControl.

    I do really hope this class design issue is addressed relatively soon as the
    ObjectDataSource is looking to be a significant player in ASP.NET 2.0, and
    it's a shame you can't effectively inherit from it.

    Darren Clark
    Lead Architect
    Ecast, Inc.
    Darren Clark, Feb 15, 2006
    #2
    1. Advertising

  3. Yeah, it kinda sucks that the control calls it's private GetView
    implementation. I think when the ASP.NET team created this control
    they weren't thinking of people extending it. If you want to find out
    more about the DataSourceControl, check out Nikhil Kothari's tutorial
    posts: http://www.nikhilk.net/DataSourceControlsSummary.aspx
    Javier G. Lozano, Feb 17, 2006
    #3
    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. Charles Siegel
    Replies:
    2
    Views:
    365
    Jonathan N. Little
    Feb 14, 2006
  2. Ronen Yacov
    Replies:
    2
    Views:
    307
    =?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=
    Oct 10, 2007
  3. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    228
    Steven Cheng[MSFT]
    Mar 23, 2006
  4. Arnaud Delobelle

    Re: Problem with ImapLib and subject in French

    Arnaud Delobelle, Jun 18, 2012, in forum: Python
    Replies:
    0
    Views:
    244
    Arnaud Delobelle
    Jun 18, 2012
  5. Dieter Maurer
    Replies:
    0
    Views:
    233
    Dieter Maurer
    Jun 18, 2012
Loading...

Share This Page