Microsoft MVP Logo

Last night I had the pleasure of watching a presentation at the Jacksonville, FL .NET User Group by Ken Getz on the new GridView control in ASP.NET 2.0 (a cut-down presentation of what he gave at VSLive a month earlier).  It was very impressive how much you can do with the GridView without writing any code (adding sorting, paging, filtering, data binding, selects, updates, inserts, deletes) except for a line here or there for certain things (literally, a line or two… like maybe 2 lines of code total).  But something stood out to me even more that was only a footnote in the presentation… something I wasn’t aware of that is included in .NET 2.0 until last night: ObjectDataSources.

We’ve all sat through demos where some presenter drags a datagrid or repeater onto a page, then creates a SqlDConnection and SqlCommand object visually, links them to a table, then binds the command to the grid.  Great… but in the real world, only novices and poorly written code does this: you never have the presentation layer accessing the data (and don’t give me that crap about ADO.NET bieng your middle-tier.  We’re supposed to design apps with 3–tiers… or more importantly, n-tiers.  The ‘n’ doesn’t stand for 2, it stands for 3 or more.  You’re supposed to build business objects that are populated with data from the data layer and then the presentation layer uses those business objects.  So, those demos are worthless except in our proof of concepts to our managers.

Well, ObjectDataSources to the rescue!  I haven’t read much up on them, but an objectdatasource is simply a control that’s a bindable datasource that you write yourself… it seems to basically inherit a interface.  I haven’t read much up on them, the link for ObjectDataSources is now in my “read when you have a moment” list on the new MSDN.  Check it out!

» MSDN: Overview of the ObjectDataSource Control

Comments powered by Disqus