I've realized that ASP.Net is getting BLOATED with lots of “RAD” tools, and making it harder and harder to do things “the ASP.NET way”
I spend hours fighting with DataGrids and GridViews. Sure they work great out of the box, but sometimes you gotta do things “outside the grid“, and thats when things get whacky... fast.
For instance, last night I'm building a GridView with a set of strongly typed domain objects (via Wilson ORMapper; fantastic library). The ObjectDataSource control just cant handle it. So now I'm already hitting bare metal. Over to the codebehind and add a couple lines:
GridView1.DataSource = quotedb.ObjectSpaceManager.GetObjectSet<QUOTEDB.SHOPPINGCARTDETAIL>(string.Format(“ShoppingCartID={0}“,shoppingCartId))
GridView1.DataBind()
Ok, great! It works! Eureka! but wait, I gotta pull the Description property from a child property from the ShoppingCartDetail instance, via ShoppingCartDetail.ProductObject.Description. Bang! GridView fails again. I guess you can't say <asp:BoundField DataField="“ProductObject.Description“" />
Ouch, bare metal again... So more codebehind:
GridView1_RowDataBound(...) {
if(e.Row.RowType == DataControlRowType.Item)
e.Cells(1).Text = ((quotedb.ShoppingCartDetail)e.Row.DataItem).ProductObject.Description;
Refresh, and viola! Description! Cool! ...except its bold? Hmmm thats bizarre. “View Source...” and it begins rendering <TH> tags around the Description? WTF? So by this time I'm furious. I've gotta REPLACE TEXT on the output html?!?! Whats the point of all this? Why does the GridView fail me everytime I step outside the box? Yeah, its better than DataGrids... don't get me started!
This is after putting down a DIFFERENT problem on the same page trying to calculate SalesTax and stuff into a cookie for the checkout page.
NOW ON THE OTHER HAND
Working with SqlDataSources and GridViews is a MAJOR improvement over DataGrids of 1.0 era. Thank God for that! Paging, sorting, and nifty client-side callbacks for Paging and Sorting... neat! But this is directly accessing the database. So its tied to my database schema very tightly.
Look the reason why I use .Net... Its a great platform over all. Fantastic. I cringe anytime I even think about code thats not managed. C++? You can have it. Java... I'll pass. Good start! But Sun's is resisting some runtime “updates“, specifically generics. (I know they'll have them, which is a start, but no perf improvements from the runtime since they just downgrade to object type anyways, with the same casting inefficiencies)
And ASP.Net's WebServices are fantastic. Decoupling along with good contracts is a fantastic way to be able to manage code/database evolution.
GridView is almost there... leagues ahead of DataGrids, but still needs more “real world” like nested properties and so forth...