Data Source Controls Summary

A summary for data source control series, a screenshot, and finally (most importantly) the source code for the data source, the designer, the sample, and the async data source framework.

Weather AppletThis post brings together the series of data source related posts (given my site has been down for the last few days, it might be a good idea to have a followup post). I hope they have been an interesting read, and also hope that the progression gives some sense of how one can incrementally build controls in general (in order to handle the inherent complexities associated with these beasts... er... tasks).

On the left is a screenshot of a Weather Applet (the applet doesn't show the data source - it is after all non-visual, but I've added it since provides some visual clue of the scenario, and I couldn't resist adding a pretty picture. :-)

  • Part 1 covered the basics of the data sources control architecture. I also wanted to get out the idea of packaging web service APIs that are starting to get popular into higher level controls, so as to enable a RAD programming model for them.
  • Part 2 covered using parameters to enable declarative transfer of values from other parts of the page into the data source and using them to automatically cause data-binding when the underlying values changed.
  • Part 3 introduced an async data source framework, and how it could be used to perform async data access in order to optimize server CPU usage.
  • Part 4 introduced encapsulation of cache usage within a data source, as an even more effective technique to optimize not only server CPU usage, but also end-user experience.
  • Part 5 finally showed the design-time experience enabled by data source controls by virtue of live data and schema.

For those who have been patient through the progression, here is the sample application and code. As usual, I appreciate any comments on this series... What do you think about data source controls, or the general model? What do you think about these sort of topics?

By the way, I just noticed John Gossman has been reading my posts, and mentioned comparing ASP.NET data sources to similar concepts in Avalon. I would love to hear more details... Based on some early experimentation, I personally noticed two key architectural differences - there is loose coupling between data sources and data consumers in Avalon... instead the coupling is at the actual data level (in fact any component with properties can be a data source for another component). Secondly, in terms of bindings themselves, Avalon's bindings are live (listen to change notifications). In contrast ASP.NET bindings pretty much execute once, where the framework is optimized for a linear page lifecycle coupled with a model where user input is processed at the start, and then there is no more of that, until a new page is rendered. I do love Avalon's data-binding model - I think it lends itself very well to declarative programming... and I am a big fan of that. In fact Ajax-ish applications are more like Avalon, since they feature the same live environment where bindings need to be live, and the coupling between objects is at the data level. We're heavily borrowing from Avalon-ish data-binding framework for the Atlas project.

Posted on Monday, 7/25/2005 @ 12:00 AM | #ASP.NET


Comments

10 comments have been posted.

Sonu Kapoor

Posted on 7/25/2005 @ 6:46 AM
That was a great datasource summary. I enjoyed it!

Ryan Dunn

Posted on 7/25/2005 @ 6:58 AM
Great work on the series - fascinating stuff and well written.

Kevin Dente

Posted on 7/25/2005 @ 3:35 PM
Great stuff - keep it coming! I'd be interested in some of the new, advanced design-time features for controls, for example. They seem under-documented at this point.

Radek

Posted on 7/28/2005 @ 10:25 AM
Good reading Nikhil. Do you have any plans for next version of your book where you could cover all DataSourceControl aspects as well ? If so - when can I buy it :) I'm serious - the book would be a tremendous contribution for control development in v2.0.

yq zhang

Posted on 8/17/2005 @ 11:22 PM
this is really very interesting, i enjoy it and will try to incorporate it on our web....

Lino

Posted on 9/26/2005 @ 10:59 AM
Thanks Nikhil, great info, much needed.
I still think it was a mistake breaking the old Non-Visual component architecture from .NET 1.1 in .NET 2.0
We used to loop through all the components on a WebForm in the designer to hoop up Visual comps to non visual comps at Designtime and now that is not possible because the new designers do not show non visual comps as part of the webforms comps anymore. The only solution is what you are discussing (Datasource like components) which are mainly visual components, they just don't render at runtime. Oh well.

The designer behavior should not have been broken in 2.0 for 3rd party component vendor sake :)
Thanks again

Diego Vega

Posted on 12/12/2005 @ 6:37 AM
For my needs, I would rather like to extend ObjectDataSource and ObjectDataSourceView than to create brand new classes. But this is impractical since most members of ObjectDataSource rely on private function GetView() to access the underlying DataSourceView. This function will always retun a standard ObjectDataSourceView from private field _view. So even if I override GetView(string) to retun my custom DataSourceView, half the DataSource control will talk to a separate instance.

What I need to implement if deferred updates, that is, an ObjectDataSource that saves intermediate updates/deletes/inserts to a temp storage until I tell it that everything is ready to send the the changes to the underlying business object. Databound controls must behave as if changes where being committed. And yes, I want to do it withoug touching the business objects. It would be wonderful to do this with inheritance and adding only minimum code (I am not a component developer, just an application developer that is hard to scare).

john

Posted on 1/6/2006 @ 8:21 AM
I've implemented an custom object datasource, but am having problems implementing paging. For some reason the gridview does not show the pager. Is there something special the gridview needs to no about paging capabilities in the datasource?

Petter Andreassen

Posted on 3/20/2006 @ 2:10 AM
I do grasp the concept of the Datasource control and the dataview.
And I thought i understood the concept behind the GetViewNames, but all the examples on the web I have found just short circutes this method to return 1 vie name.
In this weater control exmample I would blive that we could return a list of names that map to different weather services.
Am I correct?

I tried to do so in my datasource controll, but I can't find any place to choose what view to use?
The GetViews function is never called as far as I can see, and the name of the view passed ti GetView is allways blank.

What am I missing... argh.....

Manu

Posted on 3/21/2006 @ 4:19 PM
Thanks Nikhil for these excellent articles. They have been very useful for me.

I have some suggestions:
* why not make DataSourceView an interface? If you're creating a data source control with only 1 view (the usual case) you end up writing a lot of code in the data source control class that just calls the view.
* Bind expressions don't support expressions with a dot. Why not? it's up to the control to support Address.Main or not
* Components in ASP.NET have been taken out but there's a need for it and for components that interact with the lifecycle. Please bring them to life again.

Some time ago I posted about the new data source controls and the new data binding infrastructure. If you have read Nikhil's post about data source control you may find these useful:

Part 1 - http://www.manuelabadia.com/blog/PermaLink,guid,678ed6d8-dce8-40d7-9117-0ffd016fe886.aspx
Part 2 - http://www.manuelabadia.com/blog/PermaLink,guid,eba2bb6b-7006-41ae-a035-532021eb5f42.aspx
Part 3 - http://www.manuelabadia.com/blog/PermaLink,guid,e4f162b4-2adb-46d7-9d31-be32ff9b1347.aspx
Part 4 - http://www.manuelabadia.com/blog/PermaLink,guid,45f5c9da-8a03-423f-b5b6-5882c4bd67e5.aspx
The discussion on this post has been closed. Please use my contact form to provide comments.