Friday, November 05, 2004 - Posts

DataSourceControl, DataSourceView

The new Asp.Net 2.0 DataSournceControls, their underlying DataSourceView's and the new visual controls that bind to these like the FormView, GridView, etc. are really cool. I really think these things are going to help cut down a lot of the mundane aspects of form building, by providing mechanisms that will do a lot of this work in a simple declarative fashion. In my mind they will allow a lot of Asp.Net developers to implicitly follow a good mvc'ish pattern without even realizing it. Overall, I really like these controls and what they are going to give us in productivity and in terms of good autogenerated layering of responsibility between model, view and controller.

However, I was really disappointed to dig into the beta1 “out of the box” objectDataSource. I really thought this was going to allow me to extend a true Business Object as an available dataSource. Instead, what I found was simply another pass through to a DataSet. In my mind, the objectDataSource simply provides a little extra ability to abstract the fact that your DataSet is coming and going through some other object. What if I don't want to use a DataSet? So, out of the box we have 2 dataSourceControls that hook right to DB tables and views (Access and SQL), and we have 2 dataSourcesControls that hook to DataSets (the dataSetDataSource and in my mind the objectDataSource). I for one would like to see a DataSourceControl that is designed to link directly to a BusinessObject (that has standard property accessors and Save,Delete,Fetch methods, etc.

I think this weekend I'll be looking at extending the DataSourceControl and DataSourceView into my own custom BusinessObjectDataSource and BusinessObjectDataView. Don't plan on completing this over the weekend, but just evaluate what is required to do so, and test the waters a little. Ultimately, what I'm after is similar behavior to the way the existing controls work. Drop a new BODataSource control on a form, point it to a custom BO, then drop a FormView on a form and give it's DataSourceID property the ID of the BODataSource, and presto, magic, reflection, have a Form drawn on my page that has default ItemTemplates and EditTemplates based on the give BusinessObject's properties...Keeping my fingers crossed.