ASP.NET DataBinding Take 2 (or is it 3)
Nicolas Galler | November 20, 2007Well I finally bit the bullet and implemented the solution I discussed in my previous post on databinding by creating a new data source control. 2 comments:
- It was ridiculously easy
- It is fucking awesome
So now the code from my datagrid looks like this:
<asp:gridview datasourceid='dsProducts'> <columns> <DataBoundField DataField='ProductName'> </columns> </asp:gridview> <sss:SlxEntityDataSource EntitySourceProperty='Products' id='dsProducts' >
The SlxEntityDataSource retrieves the entity bound to the page and resolves the Products property. That’s pretty much it really… There is an EntityDataSourceView which contains the actual logic needed to retrieve the entity within the collection… It is also possible to just set this to a custom collection. And of course NHibernate automatically persists all this mess (with the help of Saleslogix to save it into the session until we are ready to commit it) without me having to lift one finger. Next in line is adding a small improvement to the GridView to make it possible to edit more than 1 row at a time because having to click Edit/Update every time is a bit of a drag. There is a good post for this on Matt Dotson’s blog.
Well the last comment I can make for now is what a piece of dogshit ObjectDataSource is. I wish I hadn’t spent so much time trying to make it work despite all. The ASP.NET databinding is actually starting to look pretty good!





