Vault of Thoughts

2006-06-05

Please visit my new blog at vaultofthoughts.net

MyObjectDataSource - update

I have been using MyObjectDataSource control for some time now with great success. I have however observed one thing that was missing. The missing thing was the possibility to use the container on which the control was placed as the actual TypeName object which provides the methods for Select, Insert, Update and Delete. Oh, of course it was possible before by using the TypeName and providing the name of the type that the page inherits from, but it had two major drawbacks:



  1. It required the page object to be instantiated 2 times: one for handling the request and the second time to provide an object on which the DataSource methods were called. (possible workaround was to use static methods, but then, no page state information was available)
  2. Providing a type name for a page is not so easy. It depends on few factors. By default the type name is the name of the code behind class with _aspx postfix. But it can be anything you choose by using the ClassName attribute of the Page directive in the aspx file.

So I have made some changes to the control and now if the TypeName property is not specified, the methods of the containing object are used. Further more, the same object is used as the one used to serve the request. Of course all the rest of the functionality remains unchanged. The source code and binary file is accessible here and here.


kick it on dotnetkicks.com

If you liked this article why not support its author by making a donation?

3 Comments:

  • Hello Michal,

    greate work, I love your ods. I just was wondering what licence you are using for your code? Is someone free to use it or to continue developing it?

    Best regeards

    El Gringo

    By Anonymous Anonymous, at 12:53 PM  

  • For now it may be a Let Me Know licence - i.e. let me know if you use my stuff and what do you think about it :-)

    By Blogger Mikeon, at 9:10 AM  

  • I have modified this code so now I can use
    Bind("Company.Item.Name") style two way databinding. Drop me a mail if you are interested.
    emperon@gmail.com

    By Blogger Onur Gümüş, at 8:18 PM  

Post a Comment

<< Home