locked
Accessing ObjectDataSource programmatically RRS feed

  • Question

  • User714796689 posted

    Hi,

    Is there a way of accessing an underlying instance of a class specified in the Type attribute of an ObjectDataSource?

    Thanks,

    Leszek

    Thursday, March 26, 2015 9:26 AM

All replies

  • User1918509225 posted

    Hi ata6502,

    Thanks for your post here.

    I am not quite sure why need to access the a class specified in the Type attribute of an ObjectDataSource?

    I suggest that you could refer to the tutorial in the link below:

    http://weblogs.asp.net/vardi/436712

    Best Regards,

    Kevin Shen.

    Thursday, March 26, 2015 11:34 PM
  • User714796689 posted

    Thanks Kevin for your response and the link. Unfortunately, I can't use the suggested solution as I have little control over the middle-tier object. In fact, that's why I need to access it. It requires some kind of initialization i.e., after creating it I need to call an Initialize method with certain parameters. Then, through the page lifetime, I need to access some properties of this instance.

    It seems I have found a suitable candidate for a solution: the ObjectDataSource.OnObjectCreating event handler. An idea is to manually create an instance of my middle-tier component, call the Initialize method, and then assign it to a page scope field for other methods to access. Do you think this is a good idea?

    Thanks,

    Leszek

    Friday, March 27, 2015 8:40 AM